public override int CompareTo(Object o) { int result = 0; if (o is FillStyle && this.FillType != ((FillStyle)o).FillType) { result = (this.FillType > ((FillStyle)o).FillType) ? 1 : -1; } else if (o is ImageFill) { ImageFill bf = (ImageFill)o; if (this.ImagePath != bf.ImagePath) { result = (this.ImagePath.CompareTo(bf.ImagePath)); } if (this.IsSmooth != bf.IsSmooth) { result = (this.IsSmooth) ? 1 : -1; } if (this.IsTiled != bf.IsTiled) { result = (this.IsTiled) ? 1 : -1; } else { result = this.Matrix.CompareTo(bf.Matrix); } } else { throw new ArgumentException("Objects being compared are not of the same type"); } return(result); }
public bool Equals(ImageFill o) { return( (this.ImagePath == o.ImagePath) && (this.IsSmooth == o.IsSmooth) && (this.IsTiled == o.IsTiled) && (this.Matrix == o.Matrix)); }
public bool Equals(ImageFill o) { return ( (this.ImagePath == o.ImagePath) && (this.IsSmooth == o.IsSmooth) && (this.IsTiled == o.IsTiled) && (this.Matrix == o.Matrix) ); }
private void FillPaths(Vex.FillStyle fill, List <GraphicsPath> paths) { Brush b = null; foreach (GraphicsPath path in paths) { if (fillOverride != null) { g.FillPath(fillOverride, path); } else { switch (fill.FillType) { case Vex.FillType.Solid: Vex.SolidFill sf = (Vex.SolidFill)fill; b = new SolidBrush(sf.Color.SysColor()); break; case Vex.FillType.Linear: Vex.GradientFill lf = (Vex.GradientFill)fill; RectangleF rect = Vex.GradientFill.GradientVexRect.SysRectangleF(); LinearGradientBrush lgb = new LinearGradientBrush( rect, Color.White, Color.White, 1.0F ); lgb.InterpolationColors = GetColorBlend(lf); lgb.Transform = lf.Transform.SysMatrix(); lgb.WrapMode = WrapMode.TileFlipX; ExtendGradientBrush(lgb, path); b = lgb; break; case Vex.FillType.Radial: Vex.GradientFill rf = (Vex.GradientFill)fill; ColorBlend cb = GetColorBlend(rf); SolidBrush bkgCol = new SolidBrush(cb.Colors[0]); g.FillPath(bkgCol, path); bkgCol.Dispose(); // radial fill part GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(Vex.GradientFill.GradientVexRect.SysRectangleF()); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.InterpolationColors = GetColorBlend(rf); pgb.Transform = rf.Transform.SysMatrix(); b = pgb; break; case Vex.FillType.Image: Vex.ImageFill imgFill = (Vex.ImageFill)fill; Bitmap bmp = new Bitmap(imgFill.ImagePath); b = new TextureBrush(bmp); break; default: b = new SolidBrush(Color.Red); break; } g.FillPath(b, path); } } if (b != null) { b.Dispose(); } }
private void ParseDefineBitsLossless(DefineBitsLosslessTag tag) { DDW.Vex.ImageFill bf = new DDW.Vex.ImageFill(); string path = v.ResourceFolder + @"/" + VexObject.BitmapPrefix + tag.CharacterId + ".png"; WriteLosslessBitmapToDisk(path, tag); Image img = new Vex.Image(path, v.NextId()); img.Id = tag.CharacterId; img.StrokeBounds = new Rectangle(0, 0, tag.Width, tag.Height); bitmapPaths.Add(img.Id, path); v.Definitions.Add(img.Id, img); }
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); }
private DDW.Vex.ImageFill ParseBitmapFill(BitmapFill tag) { DDW.Vex.ImageFill bf = new DDW.Vex.ImageFill(); bf.ImagePath = bitmapPaths.ContainsKey(tag.CharacterId) ? bitmapPaths[tag.CharacterId] : ""; Swf.Matrix sm = Utils.ScaleBitmapMatrix(tag.Matrix); bf.Matrix = new DDW.Vex.Matrix( sm.ScaleX, sm.Rotate0, sm.Rotate1, sm.ScaleY, (sm.TranslateX / twips), (sm.TranslateY / twips)); switch (tag.FillType) { case FillType.ClippedBitmap: bf.IsSmooth = true; bf.IsTiled = false; break; case FillType.RepeatingBitmap: bf.IsSmooth = true; bf.IsTiled = true; break; case FillType.NSClippedBitmap: bf.IsSmooth = false; bf.IsTiled = false; break; case FillType.NSRepeatingBitmap: bf.IsSmooth = false; bf.IsTiled = true; break; } return bf; }