public static EdgeCap EdgeCap(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) edge cap indicator: the following values are standardized: // 1 unspecified // 2 butt // 3 round // 4 projected square // 5 triangle // >5 reserved for registered values // P2: (index) dash cap indicator: valid values are // 1 unspecified // 2 butt // 3 match // >3 reserved for registered values return(new EdgeCap(reader.ReadIndex(), reader.ReadIndex())); }
public static FontProperties FontProperties(MetafileReader reader, CommandHeader commandHeader) { // FONT PROPERTIES: has a variable number of parameter 3-tuples (P1,P2,P3); each parameter 3-tuple contains // P1: (index) property indicator, valid values are // 1 font index // 2 standard version // 3 design source // 4 font family // 5 posture // 6 weight // 7 proportionate width // 8 included glyph collections // 9 included glyphs // 10 design size // 11 minimum size // 12 maximum size // 13 design group // 14 structure // >14 reserved for registered values // P2: (integer) priority, valid values are non-negative integers. // P3: (structured data record) property value record, each record contains a single member and is comprised of // [data type indicator, data element count, data element(s)]. var properties = new List <FontProperty>(); while (reader.HasMoreData((reader.Descriptor.IndexPrecision + reader.Descriptor.IntegerPrecision) / 8)) { int propertyIndicator = reader.ReadIndex(); int priority = reader.ReadInteger(); // The SDR for each of the standardized properties contains only one member (typed sequence) [ISO/IEC 8632-1 7.3.21] var record = ApplicationStructureDescriptorReader.ReadStructuredDataRecord(reader); properties.Add(new FontProperty(propertyIndicator, priority, record.Elements.First())); } return(new FontProperties(properties.ToArray())); }
public static MetafileElementsList MetafileElementsList(MetafileReader reader, CommandHeader commandHeader) { // P1: (integer) number of elements specified // P2: (index-pair array) List of metafile elements in this metafile. Each element is represented by two values: // the first is its element class code (as in Table 2) // the second is its element id code (as in Table 3 to Table 10). int numberOfElements = reader.ReadInteger(); // unused var elements = new List <string>(); while (reader.HasMoreData()) { int elementClass = reader.ReadIndex(); int elementId = reader.ReadIndex(); elements.Add(GetMetafileElementsListName(elementClass, elementId)); } return(new MetafileElementsList(elements)); }
public static ProtectionRegionIndicator ProtectionRegionIndicator(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) region index // P2: (index) region indicator: valid values are // 1 off // 2 clip // 3 shield return(new ProtectionRegionIndicator(reader.ReadIndex(), reader.ReadEnum <RegionIndicator>())); }
public static EdgeJoin EdgeJoin(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) edge join indicator: the following values are standardized: // 1 unspecified // 2 mitre // 3 round // 4 bevel // >4 reserved for registered values return(new EdgeJoin(reader.ReadIndex())); }
public static EdgeTypeContinuation EdgeTypeContinuation(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) continuation mode: the following values are standardized: // 1 unspecified // 2 continue // 3 restart // 4 adaptive continue // >4 reserved for registered values return(new EdgeTypeContinuation(reader.ReadIndex())); }
public static ColorModelCommand ColorModelCommand(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) colour model: valid values are // 1 RGB // 2 CIELAB // 3 CIELUV // 4 CMYK // 5 RGB - related // > 5 reserved for registered values return(new ColorModelCommand(reader.ReadIndex())); }
public static LineType LineType(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) line type: the following values are standardized: // 1 solid // 2 dash // 3 dot // 4 dash-dot // 5 dash-dot-dot // >5 reserved for registered values // negative for private use return(new LineType(reader.ReadIndex())); }
public static RestrictedTextType RestrictedTextType(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) restriction type: the following values are standardized: // 1 basic // 2 boxed-cap // 3 boxed-all // 4 isotropic-cap // 5 isotropic-all // 6 justified // >6 reserved for registered values return(new RestrictedTextType(reader.ReadIndex())); }
public static MarkerType MarkerType(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) marker type: the following values are standardized: // 1 dot // 2 plus // 3 asterisk // 4 circle // 5 cross // >5 reserved for registered values // negative for private use return(new MarkerType(reader.ReadIndex())); }
public static EdgeType EdgeType(MetafileReader reader, CommandHeader commandHeader) { // P1: (integer) edge type: the following values are standardized: // 1 solid // 2 dash // 3 dot // 4 dash-dot // 5 dash-dot-dot // >5 reserved for registered values // negative for private use // TODO: all other enumerated types use index, but this one uses integer. typo in spec? return(new EdgeType(reader.ReadIndex())); }
public static HatchIndex HatchIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) hatch index: the following values are standardized: // 1 horizontal // 2 vertical // 3 positive slope // 4 negative slope // 5 horizontal/vertical crosshatch // 6 positive/negative slope crosshatch // >6 reserved for registered values // negative for private use return(new HatchIndex(reader.ReadIndex())); }
public static GeometricPatternDefinition GeometricPatternDefinition(MetafileReader reader, CommandHeader header) { // P1: (index) geometric pattern index // P2: (name) segment identifier // P3: (point) first corner point // P4: (point) second corner point int patternIndex = reader.ReadIndex(); int segmentIdentifier = reader.ReadName(); var firstCornerPoint = reader.ReadPoint(); var secondCornerPoint = reader.ReadPoint(); return(new GeometricPatternDefinition(patternIndex, segmentIdentifier, firstCornerPoint, secondCornerPoint)); }
public static Polybezier Polybezier(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) continuity indicator: valid values are // 1: discontinuous // 2: continuous // >2 reserved for registered values // P2-Pn: (point) list of point sequences: each sequence defines a single bezier curve and contains 4 or 3 points // according to the continuity indicator values 1 or 2, respectively (if the indicator is 2, the first curve, and // only the first, is defined by 4 points). int continuityIndicator = reader.ReadIndex(); var pointSequences = ReadPointList(reader); return(new Polybezier(continuityIndicator, pointSequences.ToArray())); }
public static LineAndEdgeTypeDefinition LineAndEdgeTypeDefinition(MetafileReader reader, CommandHeader header) { // P1: (index) line type, valid values are negative. // P2: (size specification) dash cycle repeat length: see Part 1, subclause 7.1 for its form. // dash cycle repeat length is affected by LINE WIDTH SPECIFICATION MODE // P3-P(n+2): (integer) list of n dash elements int lineType = reader.ReadIndex(); double dashCycleRepeatLength = reader.ReadSizeSpecification(reader.Descriptor.LineWidthSpecificationMode); var dashElements = new List <int>(); while (reader.HasMoreData()) { dashElements.Add(reader.ReadInteger()); } return(new LineAndEdgeTypeDefinition(lineType, dashCycleRepeatLength, dashElements.ToArray())); }
public static PatternTable PatternTable(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) pattern table index // P2: (integer) nx, the dimension of colour array in the direction of the PATTERN SIZE width vector // P3: (integer) ny, the dimension of colour array in the direction of the PATTERN SIZE height vector // P4: (integer) local colour precision: valid values are as for the local colour precision parameter of CELL ARRAY. // P5: (colour array) pattern definition int index = reader.ReadIndex(); int nx = reader.ReadInteger(); int ny = reader.ReadInteger(); int localColorPrecision = reader.ReadInteger(); if (localColorPrecision == 0) { if (reader.Descriptor.ColorSelectionMode == ColorModeType.Direct) { localColorPrecision = reader.Descriptor.ColorPrecision; } else { localColorPrecision = reader.Descriptor.ColorIndexPrecision; } } // might be either 1/2/4 or 8/16/32 here; but we want byte-sizes in ReadColor if (localColorPrecision >= 8) { localColorPrecision /= 8; } var colors = new List <MetafileColor>(); int count = nx * ny; while (reader.HasMoreData() && count-- > 0) { colors.Add(reader.ReadColor(localColorPrecision)); } return(new PatternTable(index, nx, ny, colors.ToArray())); }
public static HatchStyleDefinition HatchStyleDefinition(MetafileReader reader, CommandHeader header) { // P1: (index) hatch index, valid values are negative. // P2: (enumerated) style indicator: valid values are // 0 parallel // 1 cross hatch // P3: (4(size specification)) hatch direction vectors specifier (x,y,x,y): see Part 1, subclause 7.1 for its form. // hatch direction vectors specifier is affected by INTERIOR STYLE SPECIFICATION MODE // P4: (size specification) duty cycle length: see Part 1, subclause 7.1 for its form. // duty cycle length is affected by INTERIOR STYLE SPECIFICATION MODE // P5: (integer) number of hatch lines (=n) // P6-P(5+n): (integers) list of n gap widths // P(6+n)-P(5+2n): (integers) list of n line types int hatchIndex = reader.ReadIndex(); HatchStyleIndicator styleIndicator = reader.ReadEnum <HatchStyleIndicator>(); double hatchDirectionStartX = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); double hatchDirectionStartY = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); double hatchDirectionEndX = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); double hatchDirectionEndY = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); double dutyCycleLength = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); int n = reader.ReadInteger(); var gapWidths = new List <int>(); for (int i = 0; i < n; i++) { gapWidths.Add(reader.ReadInteger()); } var lineTypes = new List <int>(); for (int i = 0; i < n; i++) { lineTypes.Add(reader.ReadInteger()); } return(new HatchStyleDefinition(hatchIndex, styleIndicator, new PointF((float)hatchDirectionStartX, (float)hatchDirectionStartY), new PointF((float)hatchDirectionEndX, (float)hatchDirectionEndY), dutyCycleLength, gapWidths.ToArray(), lineTypes.ToArray())); }
private static object ReadValue(MetafileReader reader, DataTypeIndex type) { switch (type) { case DataTypeIndex.StructuredDataRecord: return(ReadStructuredDataRecord(reader)); case DataTypeIndex.ColorIndex: return(reader.ReadIndexedColor()); case DataTypeIndex.ColorDirect: return(reader.ReadDirectColor()); case DataTypeIndex.Name: return(reader.ReadName()); case DataTypeIndex.Enumerated: return(reader.ReadEnum()); case DataTypeIndex.Integer: return(reader.ReadInteger()); case DataTypeIndex.Reserved: // TODO: what exactly does reserved mean in terms of advancing position? return(null); case DataTypeIndex.SignedInteger8bit: return(reader.ReadInteger(1, false)); case DataTypeIndex.SignedInteger16bit: return(reader.ReadInteger(2, false)); case DataTypeIndex.SignedInteger32bit: return(reader.ReadInteger(4, false)); case DataTypeIndex.Index: return(reader.ReadIndex()); case DataTypeIndex.Real: return(reader.ReadReal()); case DataTypeIndex.String: case DataTypeIndex.StringFixed: // TODO: difference between S and SF? charset/escape code handling? return(reader.ReadString()); case DataTypeIndex.ViewportCoordinate: return(reader.ReadViewportCoordinate()); case DataTypeIndex.VDC: return(reader.ReadVdc()); case DataTypeIndex.ColorComponent: return(reader.ReadColorValue()); case DataTypeIndex.UnsignedInteger8bit: return(reader.ReadInteger(1, true)); case DataTypeIndex.UnsignedInteger32Bit: return(reader.ReadInteger(4, true)); case DataTypeIndex.UnsignedInteger16bit: return(reader.ReadInteger(2, true)); case DataTypeIndex.BitStream: case DataTypeIndex.ColorList: default: // FIXME: how are those implemented? return(null); } }
public static PatternIndex PatternIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) pattern index return(new PatternIndex(reader.ReadIndex())); }
public static MarkerBundleIndex MarkerBundleIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) marker bundle index return(new MarkerBundleIndex(reader.ReadIndex())); }
public static InterpolatedInterior InterpolatedInterior(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) style: valid values are // 1 parallel // 2 elliptical // 3 triangular // >3 reserved for registered values // P2: (2n(size specification)) reference geometry: see part 1, subclause 7.1 for its form. // P3: (integer) number of stages (=m) // P4: (real) array of m stage designators // P5: (colour) array of k colour specifiers: k=3 for triangular, m+1 otherwise. int style = reader.ReadIndex(); var referenceGeometry = new List <PointF>(); var stageDesignators = new List <double>(); var colorSpecifiers = new List <MetafileColor>(); // Legal values of the style parameter are positive integers. [ISO/IEC 8632-1 7.7.43] // Values greater than 3 are reserved for future standardization and registration. if (style >= 1 && style <= 3) { // parallel: the number of scalars shall be 2. The FILL REFERENCE POINT is one defining // point of a reference line. A second defining point of the reference line is defined by // the 2 scalars, which are respectively the x and y offset of the second point from the // FILL REFERENCE POINT. // elliptical: the number of scalars shall be 4. The FILL REFERENCE POINT is the centre of a // reference ellipse. The first pair of scalars are respectively the x and y offset from // the FILL REFERENCE POINT to the first CDP of ellipse and the second pair are // respectively the x and y offset from the FILL REFERENCE POINT to the second // CDP of ellipse. // triangular: the number of scalars shall be 4. The first pair of scalars are respectively the x and // y offset from the FILL REFERENCE POINT to the second corner of a reference // triangle and the second pair are respectively the x and y offset from the FILL // REFERENCE POINT to the third corner of the reference triangle. The number of // stages shall be 0 and the list of stage designators shall be empty. int geoCount; if (style == 1) { geoCount = 2; } else { geoCount = 4; } for (int i = 0; i < geoCount / 2; i++) { double rgX = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); double rgY = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode); referenceGeometry.Add(new PointF((float)rgX, (float)rgY)); } int numberOfStages = reader.ReadInteger(); for (int i = 0; i < numberOfStages; i++) { stageDesignators.Add(reader.ReadReal()); } int numberOfColors = style == 3 ? 3 : numberOfStages + 1; for (int i = 0; i < numberOfColors; i++) { colorSpecifiers.Add(reader.ReadColor()); } } return(new InterpolatedInterior(style, referenceGeometry.ToArray(), stageDesignators.ToArray(), colorSpecifiers.ToArray())); }
public static LineBundleIndex LineBundleIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) line bundle index return(new LineBundleIndex(reader.ReadIndex())); }
public static CharacterSetIndex CharacterSetIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) character set index return(new CharacterSetIndex(reader.ReadIndex())); }
public static AlternateCharacterSetIndex AlternateCharacterSetIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) alternate character set index return(new AlternateCharacterSetIndex(reader.ReadIndex())); }
public static StructuredDataRecord ReadStructuredDataRecord(MetafileReader reader) { // overall length seems to be encoded similar to the string length [ISO/IEC 8632-3 7, Table 1, Note 12] // (ie. one byte, followed by one word if its 255). int length = reader.ReadByte(); if (length == 255) { // FIXME: does an SDR also have a long form similar to a string? length = reader.ReadWord(); } var elements = new List <StructuredDataElement>(); long startPosition = reader.Position; // require at least the number of bytes for the enum and the count; which depends on integer/index precision: // > The integer of the "data count" and the index of the "data type index" are represented respectively at the current // > Integer Precision and the current Index Precision of the metafile. [ISO/IEC 8632-1 H.2.2] // some files seem to include padding or similar, which throws this off by having an extra byte available at the end while (reader.HasMoreData((reader.Descriptor.IndexPrecision + reader.Descriptor.IntegerPrecision) / 8)) { // enum is an index at the current index precision for SDR [ISO/IEC 8632-1 H.2.2] DataTypeIndex type = (DataTypeIndex)Enum.ToObject(typeof(DataTypeIndex), reader.ReadIndex()); // count is an interger at the current integer precision for SDR [ISO/IEC 8632-1 H.2.2] int count = reader.ReadInteger(); object[] values = new object[count]; for (int i = 0; i < count; i++) { values[i] = ReadValue(reader, type); } elements.Add(new StructuredDataElement(type, values)); // only read as much as specified by length if (reader.Position - startPosition >= length) { break; } } return(new StructuredDataRecord(elements)); }
public static TextBundleIndex TextBundleIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) text bundle index return(new TextBundleIndex(reader.ReadIndex())); }
public static FillBundleIndex FillBundleIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) fill bundle index return(new FillBundleIndex(reader.ReadIndex())); }
public static EdgeBundleIndex EdgeBundleIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) edge bundle index return(new EdgeBundleIndex(reader.ReadIndex())); }
public static TextFontIndex TextFontIndex(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) text font index return(new TextFontIndex(reader.ReadIndex())); }
public static BeginProtectionRegion BeginProtectionRegion(MetafileReader reader, CommandHeader commandHeader) { // P1: (index) region index return(new BeginProtectionRegion(reader.ReadIndex())); }