Example #1
0
        public static DefineSprite buildSprite(System.String name, JPEGImage image)
        {
            TagList taglist = new TagList();

            try
            {
                DefineBits defineBits = build(image);
                taglist.defineBitsJPEG2(defineBits);

                DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, image.Width, image.Height);
                taglist.defineShape3(ds3);

                PlaceObject po2 = new PlaceObject(ds3, 1);
                po2.Matrix = new Matrix();
                // po2.setName(name);

                taglist.placeObject2(po2);
            }
            catch (System.IO.IOException ex)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                throw new System.SystemException("Error reading JPEG image " + image.Location + ". " + ex.Message);
            }
            finally
            {
                image.dispose();
            }

            return(defineSprite(name, taglist));
        }
Example #2
0
        public static DefineBits build(JPEGImage image)
        {
            DefineBits defineBits = new DefineBits(flash.swf.TagValues_Fields.stagDefineBitsJPEG2);

            try
            {
                defineBits.data = image.Data;
            }
            finally
            {
                image.dispose();
            }

            return(defineBits);
        }
		public static DefineBits build(JPEGImage image)
		{
			DefineBits defineBits = new DefineBits(flash.swf.TagValues_Fields.stagDefineBitsJPEG2);
			
			try
			{
				defineBits.data = image.Data;
			}
			finally
			{
				image.dispose();
			}
			
			return defineBits;
		}
        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);
        }
Example #5
0
        public static DefineBits build(System.String name, JPEGImage image)
        {
            DefineBits defineBits = null;

            try
            {
                defineBits      = build(image);
                defineBits.name = name;
            }
            catch (System.IO.IOException ex)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                throw new System.SystemException("Error reading JPEG image " + image.Location + ". " + ex.Message);
            }
            finally
            {
                image.dispose();
            }

            return(defineBits);
        }
		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 virtual void  DefineBitsJPEG2(SaxAttributesSupport attributes)
		{
			DefineBits db = new DefineBits(flash.swf.TagValues_Fields.stagDefineBitsJPEG2);
			int id = parseInt(getAttribute(attributes, "id"));
			createCharacter(id, db);
			if (hasAttribute(attributes, "encoding"))
			{
				if (!getAttribute(attributes, "encoding").Equals("base64"))
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					fatalError(new SAXParseException("unknown encoding " + getAttribute(attributes, "encoding"), locator));
				}
				if (hasAttribute(attributes, "src"))
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					fatalError(new SAXParseException("can only specify one of src or encoding attributes", locator));
				}
				
				text = new System.Text.StringBuilder();
			}
			else
			{
				if (!hasAttribute(attributes, "src"))
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					fatalError(new SAXParseException("must provide either src or encoding attribute", locator));
				}
				
				System.IO.FileInfo src = new System.IO.FileInfo(getAttribute(attributes, "src"));
				
				try
				{
					//UPGRADE_TODO: Constructor 'java.io.FileInputStream.FileInputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileInputStreamFileInputStream_javalangString'"
					System.IO.FileStream input = new System.IO.FileStream(getAttribute(attributes, "src"), System.IO.FileMode.Open, System.IO.FileAccess.Read);
					db.data = new sbyte[(int) SupportClass.FileLength(src)];
					SupportClass.ReadInput(input, db.data, 0, db.data.Length);
				}
				catch (System.IO.IOException e)
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
					fatalError(new SAXParseException("Unable to load DefineBitsJPEG2 src " + src.Name + ":" + e.Message, locator));
				}
			}
			stack.Add(db);
		}
		public virtual void  DefineBits(SaxAttributesSupport attributes)
		{
			if (jpegTables == null)
			{
				//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
				fatalError(new SAXParseException("DefineBits must follow JPEGTables", locator));
			}
			
			DefineBits db = new DefineBits(flash.swf.TagValues_Fields.stagDefineBits);
			int id = parseInt(getAttribute(attributes, "id"));
			createCharacter(id, db);
			
			SwfImageUtils.JPEG jpeg = loadJPEG(attributes);
			
			if (jpeg != null)
			{
				if (!ArrayUtil.equals(jpeg.table, jpegTables.data))
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					fatalError(new SAXParseException("JPEGTables data does not match, use DefineBitsJPEG2", locator));
				}
				db.data = jpeg.data;
			}
			stack.Add(db);
		}
		public static DefineShape buildImage(DefineBits tag, int width, int height)
		{
			return ImageShapeBuilder.buildImage(tag, width, height);
		}
 public static DefineShape buildImage(DefineBits tag, int width, int height)
 {
     return(ImageShapeBuilder.buildImage(tag, width, height));
 }