本文来自李明子csdn博客(http://blog.csdn.net/free1985),商业转载请联系博主获得授权,非商业转载请注明出处!
1 概述
矢量图标文件用于记录矢量图标所包含的点、线、面等矢量信息。矢量图标文件包括图标索引文件和图标数据文件两个部分。
2 图标索引文件
图标索引文件由文件头和记录组成。其中,文件头为100字节定长,记录为8字节定长。记录的存储分配如表2-1所示。
表2-1 图标索引文件记录存储分配表位 置 | 域 | 值 | 数据类型 |
Byte 0 | 图标ID | 图标ID | Long |
Byte 4 | 起始位置 | 起始位置 | Long |
3 图标数据文件
图标数据文件由一个定长的文件头和一系列变长记录组成。每一个变长记录又由一个定长的记录头和变长的记录内容组成。图标数据文件的组成如图3-1所示。
图3-1 图标数据文件组成图
3.1 文件头
图标数据文件的文件头为100字节定长,图标数据文件的文件头存储分配如表3-1所示。
位 置 | 域 | 值 | 数据类型 |
Byte 0 | File Code | 9994 | Integer |
Byte 4 | Unused | 0 | Integer |
Byte 8 | Unused | 0 | Integer |
Byte 12 | Unused | 0 | Integer |
Byte 16 | Unused | 0 | Integer |
Byte 20 | Unused | 0 | Integer |
Byte 24 | File Length | File Length | Integer |
Byte 28 | Version | 1000 | Integer |
Byte 32 | Unused | 0 | Integer |
Byte 36 | Unused | 0 | Integer |
Byte 40 | Unused | 0 | Integer |
Byte 44 | Unused | 0 | Integer |
Byte 48 | Unused | 0 | Integer |
Byte 52 | Unused | 0 | Integer |
Byte 56 | Unused | 0 | Integer |
Byte 60 | Unused | 0 | Integer |
Byte 64 | Unused | 0 | Integer |
Byte 68 | Unused | 0 | Integer |
Byte 72 | Unused | 0 | Integer |
Byte 76 | Unused | 0 | Integer |
Byte 80 | Unused | 0 | Integer |
Byte 84 | Unused | 0 | Integer |
Byte 88 | Unused | 0 | Integer |
Byte 92 | Unused | 0 | Integer |
Byte 96 | Unused | 0 | Integer |
文件长度指以字节(byte)为单位的整个文件的长度,其中包括100个字节的文件头。
3.2 记录头
记录头存储图标ID和各基本图元是否存在的标识。记录头长11字节,存储分配如表3-2所示。
位 置 | 域 | 值 | 数据类型 |
Byte 0 | 图标ID | 图标ID | Integer |
Byte 4 | 是否存在多点数据 | 0不存在1存在 | BYTE |
Byte 5 | 是否存在折线 | 0不存在1存在 | BYTE |
Byte 6 | 是否存在填充多边形 | 0不存在1存在 | BYTE |
Byte 7 | 是否存在文字 | 0不存在1存在 | BYTE |
Byte 8 | 是否存在椭圆 | 0不存在1存在 | BYTE |
Byte 9 | 是否存在弧形 | 0不存在1存在 | BYTE |
Byte 10 | 是否存在箭头 | 0不存在1存在 | BYTE |
上表中,图标ID与数据库中的图标ID对应。一个图标的记录长度是图标所有数据内容部分的长度,以字节为单位。
3.3 记录内容
文件的记录内容包括图形几何类型和紧随其后的图形几何数据两部分。图形几何类型规定了图形文件所描述的几何类型。图形几何类型的定义如表3-3所示。
类型值 | 要素类型 | 类型说明 |
0 | Null Shape | 空图形 |
1 | MultiPoint | 多点 |
2 | PolyLine | 线 |
3 | Polygon | 填充多边形 |
4 | Text | 文字 |
5 | Ellipse | 椭圆 |
6 | Arc | 弧 |
7 | Arrow | 箭头 |
3.3.1 空图形(Null Shapes)
图形几何类型为0代表空图形,即在图形中没有几何数据。空图形记录的存储分配如表3-4所示。
位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 0 | Integer | 1 |
3.3.2 多点(MultiPoint)
单点数据的逻辑结构如下:
struct Point
{
float X; // X 坐标
float Y; // Y 坐标
};
多点数据表示单点的集合,逻辑结构如下:
MultiPoint
{
Interger NumPoints // 点的个数
Point [NumPoints] Point // 点的坐标数据
}
图形几何类型为1代表多点。多点记录的存储分配如表3-5所示。
表3-5 多点记录存储分配表位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 1 | Integer | 1 |
Byte 4 | NumPoints | 点个数 | Integer | 1 |
Byte 8 | Point | Point | Point | NumPoints |
3.3.3 线(PolyLine)
单点数据的逻辑结构如下:
struct Point
{
float x;
float y;
};
颜色数据的逻辑结构如下:
struct Color
{
float r;
float g;
float b;
};
线属性的逻辑结构如下:
struct LineStatus
{
Integer Parts; // Index to first point in part
Integer Type; // Type number of the line
Integer Width; // Width of the line
Color Linecolor; // The color of the line
BYTE IsVariable; // If the color is variable
Integer StackedLevel // stacked-level,from 1 on,1 is the top.
Integer ElementType // element type
}
线数据是由一条或多条折线组成的,而这些折线没有必要相互连接。每一条折线是由一组有序的节点组成的。线数据逻辑结构如下:
PolyLine
{
Integer NumPoints // Total Number of Points
Integer NumParts // Number of Parts
Point[NumPoints] Points // Points for all parts
LineStatus[NumParts] LineStatus // Index to first Point in Part and the status of the part
}
上述结构中各属性说明如下:
NumPoints | 在PolyLine中所有折线所包含的点数; |
NumParts | 在PolyLine中折线的条数; |
Point | 长度为NumPoint的数组。在PolyLine里每一条折线的点都是按顺序存储的。Parts数组里存储着关于每一条折线的起始点的索引。在各个折线之间的点数组中间没有分隔符; |
LineStatus | 长度为NumPart的数组。为每一条折线存储它在点数组里第一点的索引、线型、线宽、线色、颜色是否可变、叠放层次、图元类型。 |
线记录的存储分配如表3-6所示。
位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 2 | Integer | 1 |
Byte 4 | NumPoints | NumPoints | Integer | 1 |
Byte 8 | NumParts | NumParts | Integer | 1 |
Byte 12 | Point | Point | Point | NumPoints |
Byte X | LineStatus | LineStatus | LineStatus | NumParts |
注:X = 12 + 8*NumPoints |
3.3.4 填充多边形(Polygon)
一个多边形是由一个或多个环组成的。这些由四个或更多个点组成的环是封闭的、非交叉的。一个多边形也许包括许多外部环。一个观察者按节点顺序沿着环走,他的右侧为多边形的内侧。所以,对于一个单独环状封闭的多边形而言,它的节点顺序永远是顺时针方向的。
多边形的存储应满足以下要求:
- 各环都是封闭的(环的始末点坐标值相同);
- 在点数组中环的顺序是无关紧要的;
- 存储在文件里的多边形的线段不能自交。一个单独环状闭合的多边形总是顺时针方向,其内部的“洞”多边形必须是逆时针方向。
下面介绍填充多边形的逻辑结构。
单点数据的逻辑结构如下:
struct Point
{
float x;
float y;
};
颜色数据的逻辑结构如下:
struct Color
{
float r;
float g;
float b;
};
多边形属性的逻辑结构如下:
struct PolygonStatus
{
Integer Parts; // Index to first point in part
Color color; // The color of the line
BYTE IsVariable; // If the color is variable
Integer StackedLevel // stacked-level,from 1 on,1 is the top.
Integer ElementType // element type
}
多边形的存储结构与线是相同的,逻辑结构如下:
Polygon
{
Integer NumPoints // Total Number of Points
Integer NumParts // Number of Parts
Integer[NumPoints] Point // Points for all Parts
Integer[NumParts] PolygonStatus // Index to first Point in Part and the status of the part
}
上述结构中各属性说明如下:
Numpoints | 多边形里所有环包含的总点数,允许重复点; |
NumParts | 多边形里的环数; |
Point | 长度为NumPoint的数组。在多边形中每一个环的点都是按顺序存储的。在parts数组里保存着每一个环的起始点的索引。在各环之间的点数组中间没有分隔符; |
PolygonStatus | 长度为NumPart的数组,为每个环存储它在点数组中第一点的索引、颜色、颜色是否可变、叠放层次、图元类型; |
图3-2是一个多边形示例。
图3-2 多边形示例
这个多边形共计8个节点,并且内部有一个“洞”多边形,其NumParts为2,NumPoints为10。点的存储逻辑如图3-3所示:
图3-3 多边形示例存储
多边形的存储分配如表3-7所示。
表3-7 多边形记录存储分配表位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 | |
Byte 0 | Shape Type | 3 | Integer | 1 | |
Byte 4 | NumPoints | NumPoints | Integer | 1 | |
Byte 8 | NumParts | NumParts | Integer | 1 | |
Byte 12 | Point | Point | Point | Numpoints | |
Byte X | PolygonStatus | PolygonStatus | PolygonStatus | NumParts |
3.3.5 文字(Text)
文字内容是由一个或多个文字组成的,存放于一个11字节的字符数组中,最多可存储5个汉字或10个英文字母。
文字偏移的逻辑结构如下:
struct TextTranslate
{
float x; // X轴上的偏移量
float y;
};
颜色的逻辑结构如下:
struct Color
{
float r;
float g;
float b;
};
文字的逻辑结构如下:
Text
{
Char[11] Chars; // DChar for all Text
TextScalef;
RotatefZ;
TextTranslate;
Color;
BYTE IsVariable; // If the color is variable
}
上述结构中各属性说明如下:
Chars | 包含的文字数据。 |
Texttranslate | 文字偏移量 |
RotatefZ | 文字旋转角度 |
Color | 文字颜色 |
IsVariable | 文字颜色是否可变 |
文字的存储分配如表3-8所示。
位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 4 | Integer | 1 |
Byte 4 | Chars | Chars | Char | 11 |
Byte 16 | TextScalef | TextScalef | float | 1 |
Byte 20 | RotatefZ | RotatefZ | float | 1 |
Byte 24 | Texttranslate | Texttranslate | Texttranslate | 1 |
Byte 32 | Color | Color | Color | 1 |
Byte 44 | IsVariable | IsVariable | BYTE | 1 |
3.3.6 椭圆(Ellipse)
单点数据的逻辑结构如下:
struct Point
{
float x;
float y;
};
椭圆状态逻辑结构如下:
struct EllipseStatus
{
Point p0;
Point p1;
Point p2;
Int Type;
Int Width;
Color EllipseColor;
BYTE IsVariable;
BYTE IsFilled;
Int StackedLevel;
};
上述结构中各属性说明如下:
p0,p1,p2 椭圆外切矩形中三个切点的坐标
椭圆的逻辑结构如下:
Ellipse
{
Integer NumParts;
EllipseStatus[NumParts] EllipseStatus;
}
椭圆的存储分配如表3-9所示。
表3-9 椭圆记录存储分配表位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 5 | Integer | 1 |
Byte 4 | NumParts | NumParts | Integer | 1 |
Byte 8 | EllipseStatus | EllipseStatus | EllipseStatus | NumParts |
3.3.7 弧(Arc)
单点数据的逻辑结构如下:
struct Point
{
float x;
float y;
};
弧状态逻辑结构如下:
struct ArcStatus
{
Point Center;
Point BeginPoint;
Point EndPoint;
Int Type;
Int Width;
Color ArcColor;
BYTE IsVariable;
BYTE IsFilled
Int StackedLevel;
Integer ElementType // 图元类型,0为弧;1为弓形;2为扇形
};
上述结构中各属性说明如下:
Center | 圆心坐标 |
BeginPoint | 起点坐标 |
EndPoint | 终点坐标 |
ElementType | 图元类型 |
弧的逻辑结构如下:
Arc
{
Integer NumParts;
ArcStatus [NumParts] ArcStatus;
}
弧的存储分配如表3-10所示。
表3-10 弧记录存储分配表位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 6 | Integer | 1 |
Byte 4 | NumParts | NumParts | Integer | 1 |
Byte 8 | ArcStatus | ArcStatus | ArcStatus | NumParts |
3.3.8 箭头(Arrow)
单点数据的逻辑结构如下:
struct Point
{
float x;
float y;
};
箭头状态逻辑结构如下:
struct ArrowStatus
{
Point points[5];
Color ArrowColor;
BYTE IsVariable;
Int StackedLevel;
};
箭头的逻辑结构如下:
Arrow
{
Integer NumParts;
ArrowStatus [NumParts] ArrowStatus;
}
箭头的存储分配如表3-11所示。
表3-11 箭头记录存储分配表位置 (字节) | 域 名 | 值 | 数据类型 | 数 量 |
Byte 0 | Shape Type | 7 | Integer | 1 |
Byte 4 | NumParts | NumParts | int | 1 |
Byte 8 | ArrowStatus | ArrowStatus | ArrowStatus | NumParts |