Пример #1
0
        private void ParseDefineBits(DefineBitsTag tag)
        {
            //DDW.Vex.ImageFill bf = new DDW.Vex.ImageFill();
            //string path = v.ResourceFolder + @"/" + VexObject.BitmapPrefix + tag.CharacterId + ".jpg";
            //WriteJpegToDisk(path, tag);
            //Size sz = Utils.GetJpgSize(path);

            //if (tag.HasAlphaData) // this is an alpha jpg, convert to png
            //{
            //    byte[] alphaData = SwfReader.Decompress(tag.CompressedAlphaData, (uint)(sz.Width * sz.Height));

            //    string bmpPath = path;
            //    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpPath, false);
            //    path = v.ResourceFolder + @"/" + VexObject.BitmapPrefix + tag.CharacterId + ".png";

            //    Utils.WriteAlphaJpg(alphaData, bmp, path);

            //    bmp.Dispose();
            //    File.Delete(bmpPath);
            //}

            //Image img = new Vex.Image(path, v.NextId());
            //img.Id = tag.CharacterId;
            //img.StrokeBounds = new Rectangle(0, 0, sz.Width, sz.Height);

            //bitmapPaths.Add(img.Id, path);
            //v.Definitions.Add(img.Id, img);
        }
Пример #2
0
		private void WriteJpegToDisk(string path, DefineBitsTag tag)
		{
            IOUtils.EnsurePath(path);
			FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
			if (!tag.HasOwnTable)
			{
				fs.Write(jpegPrefix, 0, jpegPrefix.Length);
				fs.Write(swf.JpegTable.JpegTable, 0, swf.JpegTable.JpegTable.Length);
				fs.Write(tag.JpegData, 0, tag.JpegData.Length);
				fs.Write(jpegSuffix, 0, jpegSuffix.Length);
			}
			else
			{
				fs.Write(tag.JpegData, 0, tag.JpegData.Length);
			}
			fs.Close();
		}