public static NonUniformRationalBSpline NonUniformRationalBSpline(MetafileReader reader) { int splineOrder = reader.ReadInteger(); int numberOfControlPoints = reader.ReadInteger(); var controlPoints = new List <PointF>(); for (int i = 0; i < numberOfControlPoints; i++) { controlPoints.Add(reader.ReadPoint()); } var knots = new List <double>(); for (int i = 0; i < splineOrder + numberOfControlPoints; i++) { knots.Add(reader.ReadReal()); } double start = reader.ReadReal(); double end = reader.ReadReal(); var weights = new List <double>(); for (int i = 0; i < numberOfControlPoints; i++) { weights.Add(reader.ReadReal()); } return(new NonUniformRationalBSpline(splineOrder, controlPoints.ToArray(), knots.ToArray(), start, end, weights.ToArray())); }
public static CellArray CellArray(MetafileReader reader) { var p = reader.ReadPoint(); var q = reader.ReadPoint(); var r = reader.ReadPoint(); int nx = reader.ReadInteger(); int ny = reader.ReadInteger(); // TODO: not really used in text encoding; but in case we ever need it, // the same check for zero as in binary encoding needs to happen. // intentionally unused until that time comes. int localColorPrecision = reader.ReadInteger(); int totalCount = nx * ny; var colors = new List <MetafileColor>(); while (reader.HasMoreData()) { colors.Add(reader.ReadColor()); } // FIXME: for parenthesized lists, every row is enclosed by parenthesis (which right now are ignored by the parser). // The number of cells between parentheses shall be less than or equal to the row length. // If a row is not complete, then the last defined cell in the row is replicated to fill the row. // Since the parser ignores parenthesis, we can only fill the last row with the last color of all rows; // but not every row with the last color of each row. if (colors.Count < totalCount) { var lastColor = colors.Last(); colors.AddRange(Enumerable.Range(0, totalCount - colors.Count).Select(i => lastColor)); } return(new CellArray(p, q, r, nx, ny, colors.ToArray())); }
public static HatchStyleDefinition HatchStyleDefinition(MetafileReader reader) { int hatchIndex = reader.ReadIndex(); HatchStyleIndicator styleIndicator = ParseHatchStyleIndicator(reader.ReadEnum()); 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())); }
public static BeginTileArray BeginTileArray(MetafileReader reader) { return(new BeginTileArray( reader.ReadPoint(), ParseCellPathDirection(reader.ReadEnum()), ParseLineProgressionDirection(reader.ReadEnum()), reader.ReadInteger(), reader.ReadInteger(), reader.ReadInteger(), reader.ReadInteger(), reader.ReadReal(), reader.ReadReal(), reader.ReadInteger(), reader.ReadInteger(), reader.ReadInteger(), reader.ReadInteger())); }
public static PatternTable PatternTable(MetafileReader reader) { int index = reader.ReadIndex(); int nx = reader.ReadInteger(); int ny = reader.ReadInteger(); // TODO: not really used in text encoding; but in case we ever need it, // the same check for zero as in binary encoding needs to happen. // intentionally unused until that time comes. int localColorPrecision = reader.ReadInteger(); var colors = new List <MetafileColor>(); int count = nx * ny; while (reader.HasMoreData(3) && count-- > 0) { colors.Add(reader.ReadColor()); } return(new PatternTable(index, nx, ny, colors.ToArray())); }
public static InterpolatedInterior InterpolatedInterior(MetafileReader reader) { 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 LineAndEdgeTypeDefinition LineAndEdgeTypeDefinition(MetafileReader reader) { 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 FontProperties FontProperties(MetafileReader reader) { var properties = new List <FontProperty>(); while (reader.HasMoreData()) { 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.ParseStructuredDataRecord(reader.ReadString()); properties.Add(new FontProperty(propertyIndicator, priority, record.Elements.First())); } return(new FontProperties(properties.ToArray())); }
public static VdcRealPrecision VdcRealPrecision(MetafileReader reader) { double minValue = reader.ReadReal(); double maxValue = reader.ReadReal(); // assume floating point; with their respective values from the binary encoding (also ANSI/IEEE 754 stuff) int exponentWidth = 12; int fractionWidth = 52; if ((float)minValue >= float.MinValue && (float)maxValue <= float.MaxValue) { exponentWidth = 9; fractionWidth = 23; } // TODO: same as MetafileDescriptorReader.RealPrecision int significantDigits = reader.ReadInteger(); return(new VdcRealPrecision(RealRepresentation.FloatingPoint, exponentWidth, fractionWidth)); }
public static RealPrecision RealPrecision(MetafileReader reader) { double minValue = reader.ReadReal(); double maxValue = reader.ReadReal(); // assume floating point; with their respective values from the binary encoding (also ANSI/IEEE 754 stuff) int exponentWidth = 12; int fractionWidth = 52; if ((float)minValue >= float.MinValue && (float)maxValue <= float.MaxValue) { exponentWidth = 9; fractionWidth = 23; } // TODO: unless writing metafiles, we probably don't really care about the number of significant digits // at least we don't for reading, and unless we should, we'll just ignore it here (intentionally unused) int significantDigits = reader.ReadInteger(); return(new RealPrecision(RealRepresentation.FloatingPoint, exponentWidth, fractionWidth)); }
public static EscapeCommand Escape(MetafileReader reader) { int identifier = reader.ReadInteger(); string dataRecordString = reader.ReadString(); // attempt to parse the data record as structured record, in case it is a known one // otherwise it is probably application specific and cannot be assumed to be a structured record StructuredDataRecord dataRecord; if (EscapeCommand.KnownEscapeTypes.ContainsKey(identifier)) { dataRecord = ApplicationStructureDescriptorReader.ParseStructuredDataRecord(dataRecordString); } else { dataRecord = new StructuredDataRecord(new[] { new StructuredDataElement(DataTypeIndex.String, new object[] { dataRecordString }), }); } return(new EscapeCommand(identifier, dataRecord)); }
public static IntegerPrecision IntegerPrecision(MetafileReader reader) { return(new IntegerPrecision(TextEncodingHelper.GetBitPrecision(reader.ReadInteger(), reader.ReadInteger()))); }
public static SegmentPriorityExtent SegmentPriorityExtent(MetafileReader reader) { return(new SegmentPriorityExtent(reader.ReadInteger(), reader.ReadInteger())); }
public static ColorModelCommand ColorModelCommand(MetafileReader reader) { // {1=RGB, 2=CIELAB, 3 = CIELUV, 4 = CMYK, 5 = RGB - related, > 5, reserved for registered values} return(new ColorModelCommand(reader.ReadInteger())); }
public static MetafileVersion MetafileVersion(MetafileReader reader) { return(new MetafileVersion(reader.ReadInteger())); }
public static ColorIndexPrecision ColorIndexPrecision(MetafileReader reader) { return(new ColorIndexPrecision(TextEncodingHelper.GetBitPrecision(reader.ReadInteger()))); }
public static SegmentPickPriority SegmentPickPriority(MetafileReader reader) { return(new SegmentPickPriority(reader.ReadName(), reader.ReadInteger())); }
public static ApplicationData ApplicationData(MetafileReader reader) { return(new ApplicationData(reader.ReadInteger(), reader.ReadString())); }