public static Matrix build(System.Drawing.Drawing2D.Matrix at) { Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleX = (int)System.Math.Round((double)((float)at.Elements.GetValue(0) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleY = (int)System.Math.Round((double)((float)at.Elements.GetValue(3) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); if (matrix.scaleX != 0 || matrix.scaleY != 0) { matrix.hasScale = true; } //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.rotateSkew0 = (int)System.Math.Round((double)((float)at.Elements.GetValue(1) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //Yes, these are supposed //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.rotateSkew1 = (int)System.Math.Round((double)((float)at.Elements.GetValue(2) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //to be flipped if (matrix.rotateSkew0 != 0 || matrix.rotateSkew1 != 0) { matrix.hasRotate = true; //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.getType' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformgetType'" //UPGRADE_ISSUE: Field 'java.awt.geom.AffineTransform.TYPE_MASK_ROTATION' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformTYPE_MASK_ROTATION_f'" if ((at.getType() & AffineTransform.TYPE_MASK_ROTATION) != 0) { matrix.hasScale = true; //A rotation operation in Flash requires both rotate and scale components, even if zero scale. } } //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateX = (int)System.Math.Round((double)((System.Single)at.OffsetX * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateY = (int)System.Math.Round((double)((System.Single)at.OffsetY * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); return(matrix); }
public static Matrix build(System.Drawing.Drawing2D.Matrix at) { Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleX = (int) System.Math.Round((double) ((float) at.Elements.GetValue(0) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleY = (int) System.Math.Round((double) ((float) at.Elements.GetValue(3) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); if (matrix.scaleX != 0 || matrix.scaleY != 0) matrix.hasScale = true; //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.rotateSkew0 = (int) System.Math.Round((double) ((float) at.Elements.GetValue(1) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //Yes, these are supposed //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.rotateSkew1 = (int) System.Math.Round((double) ((float) at.Elements.GetValue(2) * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //to be flipped if (matrix.rotateSkew0 != 0 || matrix.rotateSkew1 != 0) { matrix.hasRotate = true; //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.getType' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformgetType'" //UPGRADE_ISSUE: Field 'java.awt.geom.AffineTransform.TYPE_MASK_ROTATION' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformTYPE_MASK_ROTATION_f'" if ((at.getType() & AffineTransform.TYPE_MASK_ROTATION) != 0) matrix.hasScale = true; //A rotation operation in Flash requires both rotate and scale components, even if zero scale. } //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateX = (int) System.Math.Round((double) ((System.Single) at.OffsetX * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateY = (int) System.Math.Round((double) ((System.Single) at.OffsetY * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); return matrix; }
public static Matrix getTranslateInstance(double tx, double ty) { Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateX = (int) System.Math.Round((double) (tx * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateY = (int) System.Math.Round((double) (ty * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); return matrix; }
public static Matrix getTranslateInstance(double tx, double ty) { Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateX = (int)System.Math.Round((double)(tx * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.translateY = (int)System.Math.Round((double)(ty * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL)); return(matrix); }
public static DefineShape buildImage(DefineBits tag, int width, int height) { // Create Fill Style Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleX = (int)System.Math.Round((double)(flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleY = (int)System.Math.Round((double)(flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); matrix.hasScale = true; //Apply runtime scale of 20 (for twips) FillStyle fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag); // Apply Fill Styles ShapeWithStyle sws = new ShapeWithStyle(); sws.fillstyles = new System.Collections.ArrayList(); //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" int fsIndex = sws.fillstyles.Add(fs) >= 0?sws.fillstyles.LastIndexOf(fs) + 1:0; sws.linestyles = new System.Collections.ArrayList(); // Build Raw SWF Shape ShapeBuilder builder = new ShapeBuilder(new Point()); builder.UseFillStyle0 = true; builder.CurrentFillStyle0 = fsIndex; builder.move(0, 0); builder.straight(width, 0); builder.straight(width, height); builder.straight(0, height); builder.straight(0, 0); builder.correctRoundingErrors(); sws.shapeRecords = builder.build().shapeRecords; // Wrap up into a SWF DefineShape Tag DefineShape defineShape = new DefineShape(flash.swf.TagValues_Fields.stagDefineShape3); defineShape.bounds = new Rect(width * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL); defineShape.shapeWithStyle = sws; return(defineShape); }
public static DefineShape buildImage(DefineBits tag, int width, int height) { // Create Fill Style Matrix matrix = new Matrix(); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleX = (int) System.Math.Round((double) (flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" matrix.scaleY = (int) System.Math.Round((double) (flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE)); matrix.hasScale = true; //Apply runtime scale of 20 (for twips) FillStyle fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag); // Apply Fill Styles ShapeWithStyle sws = new ShapeWithStyle(); sws.fillstyles = new System.Collections.ArrayList(); //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" int fsIndex = sws.fillstyles.Add(fs) >= 0?sws.fillstyles.LastIndexOf(fs) + 1:0; sws.linestyles = new System.Collections.ArrayList(); // Build Raw SWF Shape ShapeBuilder builder = new ShapeBuilder(new Point()); builder.UseFillStyle0 = true; builder.CurrentFillStyle0 = fsIndex; builder.move(0, 0); builder.straight(width, 0); builder.straight(width, height); builder.straight(0, height); builder.straight(0, 0); builder.correctRoundingErrors(); sws.shapeRecords = builder.build().shapeRecords; // Wrap up into a SWF DefineShape Tag DefineShape defineShape = new DefineShape(flash.swf.TagValues_Fields.stagDefineShape3); defineShape.bounds = new Rect(width * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL); defineShape.shapeWithStyle = sws; return defineShape; }
private Matrix parseMatrix(System.String s) { Matrix matrix = new Matrix(); for (int i = 0; i < s.Length; i++) { char c = s[i]; switch (c) { case 'r': i++; System.String[] parts = StringUtils.split(s.Substring(i), "[, ]", 3); matrix.setRotate(System.Double.Parse(parts[0]), System.Double.Parse(parts[1])); break; case 's': i++; parts = StringUtils.split(s.Substring(i), "[, ]", 3); matrix.setScale(System.Double.Parse(parts[0]), System.Double.Parse(parts[1])); break; case 't': i++; parts = StringUtils.split(s.Substring(i), "[, ]", 3); matrix.translateX = System.Int32.Parse(parts[0]); matrix.translateY = System.Int32.Parse(parts[1]); break; } } return matrix; }
private void encodeMatrix(Matrix matrix, SwfEncoder w) { w.writeBit(matrix.hasScale); if (matrix.hasScale) { int nScaleBits = matrix.nScaleBits(); w.writeUBits(nScaleBits, 5); w.writeSBits(matrix.scaleX, nScaleBits); w.writeSBits(matrix.scaleY, nScaleBits); } w.writeBit(matrix.hasRotate); if (matrix.hasRotate) { int nRotateBits = matrix.nRotateBits(); w.writeUBits(nRotateBits, 5); w.writeSBits(matrix.rotateSkew0, nRotateBits); w.writeSBits(matrix.rotateSkew1, nRotateBits); } int nTranslateBits = matrix.nTranslateBits(); w.writeUBits(nTranslateBits, 5); w.writeSBits(matrix.translateX, nTranslateBits); w.writeSBits(matrix.translateY, nTranslateBits); w.flushBits(); }
/// <summary> Utility method to create an appropriate <code>FillStyle</code> from a <code>Paint</code>.</summary> /// <param name="paint">an AWT <code>Paint</code> instance /// </param> /// <param name="bounds">- required for gradient ratio calculation /// </param> /// <returns> a new <code>FillStyle</code> representing the given paint /// </returns> //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" public static FillStyle build(System.Drawing.Brush paint, ref System.Drawing.RectangleF bounds, System.Drawing.Drawing2D.Matrix transform) { FillStyle fs = null; if (paint != null) { double width = (double)bounds.Width; double height = (double)bounds.Height; if (paint is System.Drawing.Color) { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs = new FillStyle(SwfUtils.colorToInt(ref new System.Drawing.Color[] { (System.Drawing.Color)paint }[0])); } else if (paint is System.Drawing.Drawing2D.LinearGradientBrush) { System.Drawing.Drawing2D.LinearGradientBrush gp = (System.Drawing.Drawing2D.LinearGradientBrush)paint; //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.transform' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformtransform_javaawtgeomPoint2D_javaawtgeomPoint2D'" System.Drawing.PointF tempAux = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux2 = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux3 = transform.transform(new System.Drawing.PointF(gp.Rectangle.X, gp.Rectangle.Y), tempAux); //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.PointF tempAux4 = transform.transform(new System.Drawing.PointF(gp.Rectangle.Height, gp.Rectangle.Width), tempAux2); System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux3, ref tempAux4, width, height, width, height); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); fs.type = FillStyle.FILL_LINEAR_GRADIENT; fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[2]; System.Drawing.Color tempAux5 = (gp.LinearColors)[0]; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(ref tempAux5)); //from left System.Drawing.Color tempAux6 = (gp.LinearColors)[1]; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[1] = new GradRecord(255, SwfUtils.colorToInt(ref tempAux6)); //to right } else if (paint is LinearGradientPaint) { LinearGradientPaint lgp = (LinearGradientPaint)paint; System.Drawing.PointF start = lgp.getStartPoint(); System.Drawing.PointF end = lgp.getEndPoint(); //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref start, ref end, width, height, width, height); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); System.Drawing.Color[] colors = lgp.getColors(); float[] ratios = lgp.getFractions(); if (colors.Length == 0 || colors.Length != ratios.Length) //Invalid fill so we skip { return(null); } else if (colors.Length == 1) //Solid fill { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(new FillStyle(SwfUtils.colorToInt(ref colors[0]))); } else { fs.type = FillStyle.FILL_LINEAR_GRADIENT; //Maximum of 8 gradient control points records int len = ratios.Length; if (len > 8) { len = 8; } fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[len]; for (int i = 0; i < len; i++) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i])); } } } else if (paint is RadialGradientPaint) { RadialGradientPaint rgp = (RadialGradientPaint)paint; //Note: Flash doesn't support the focal point of a radial gradient //Point2D cp = rgp.getCenterPoint(); //Point2D fp = rgp.getFocusPoint(); double diameter = rgp.getRadius() * 2.0; double outerX = diameter * rgp.getTransform().getScaleX(); double outerY = diameter * rgp.getTransform().getScaleY(); System.Drawing.PointF tempAux7 = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux8 = System.Drawing.PointF.Empty; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux7, ref tempAux8, width, height, outerX, outerY); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); fs.type = FillStyle.FILL_RADIAL_GRADIENT; System.Drawing.Color[] colors = rgp.getColors(); float[] ratios = rgp.getFractions(); fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[ratios.Length <= 8?ratios.Length:8]; for (int i = 0; i < ratios.Length && i < 8; i++) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i])); } } else if (paint is System.Drawing.TextureBrush) { System.Drawing.TextureBrush tp = (System.Drawing.TextureBrush)paint; System.Drawing.Image image = (System.Drawing.Image)tp.Image; DefineBitsLossless tag = DefineBitsLosslessBuilder.build(new LosslessImage(image)); //Apply Twips Scale of 20 x 20 System.Drawing.Drawing2D.Matrix at = new System.Drawing.Drawing2D.Matrix(); at.Scale((System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, (System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL); Matrix matrix = MatrixBuilder.build(at); fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag); } } return(fs); }