public Bitmap(ISwfDefinitionTag tag, ISystemServices services) { Texture2D texture; if (tag is DefineBitsLosslessTag) { var t = tag as DefineBitsLosslessTag; texture = new Texture2D(services.GraphicsDevice, t.Width, t.Height, false, SurfaceFormat.Color); texture.SetData(t.Pixels); } else if (tag is DefineBitsTag) { var t = tag as DefineBitsTag; var t3 = tag as DefineBitsJPEG3Tag; texture = Texture2D.FromStream(services.GraphicsDevice, new MemoryStream(t.ImageData)); if (t3 != null && t3.HasAlpha) { var alpha = Swf.BitmapUtils.DecompressAlphaValues(t3.CompressedAlpha, texture.Width, texture.Height); var data = new Color[texture.Width * texture.Height]; texture.GetData(data); for (int i = data.Length - 1; i >= 0; data[i].A = alpha[i], i--) ; texture.SetData(data); } } else throw new InvalidOperationException("Tag does not define bitmap!"); ID = tag.CharacterID; Image = services.VectorDevice.CreateImage(texture, false, false); }
public Shape(ISwfDefinitionTag tag, ISystemServices services, FlashDocument document) { var state = services.VectorDevice.State; var t = tag as DefineShapeTag; var shapes = t.Shape.SubShapes; ID = tag.CharacterID; Bounds = t.ShapeBounds; _subShapes = new SubShape[shapes.Length]; for (int s = 0; s < _subShapes.Length; s++) { var subShape = _subShapes[s] = new SubShape(); var shape = shapes[s]; subShape._fills = new SubShapeFill[shape.Fills.Count]; subShape._strokes = new SubShapeStroke[shape.Lines.Count]; var paints = new List<VGPaint>(shape.Fills.Count + shape.Lines.Count); int i = 0; VGPaint paint; foreach (var f in shape.Fills) { paints.Add(paint = MakeFill(f.Key, services.VectorDevice, document)); subShape._fills[i++] = new SubShapeFill { Paint = paint, FillMatrix = f.Key.Matrix, Path = services.VectorDevice.PreparePath(f.Value.GetPath(), VGPaintMode.Fill) }; } i = 0; foreach (var l in shape.Lines) { paint = l.Key.HasFill ? MakeFill(l.Key.Fill, services.VectorDevice, document) : services.VectorDevice.CreateColorPaint(l.Key.Color); paints.Add(paint); state.StrokeStartCap = l.Key.StartCapStyle; state.StrokeEndCap = l.Key.EndCapStyle; state.StrokeJoin = l.Key.JoinStyle; state.StrokeMiterLimit = (float)l.Key.MiterLimit; subShape._strokes[i++] = new SubShapeStroke { Paint = paint, Path = services.VectorDevice.PreparePath(l.Value.GetPath(), VGPaintMode.Stroke), Thickness = l.Key.Width, FillMatrix = l.Key.HasFill ? l.Key.Fill.Matrix : VGMatrix.Identity, ScaleX = !l.Key.NoHScale, ScaleY = !l.Key.NoVScale }; } subShape._paints = paints.ToArray(); } }
public ButtonInfo(ISwfDefinitionTag tag, ISystemServices services, FlashDocument document) { if (tag is DefineButtonTag) tag = new DefineButton2Tag(tag as DefineButtonTag); var b = tag as DefineButton2Tag; CxForm = null; TrackAsMenu = b.TrackAsMenu; Actions = b.Actions; ID = tag.CharacterID; Parts = b.Parts .Where(r => r.Up || r.Down || r.Over) .OrderBy(r => r.CharacterDepth) .Select(r => new ButtonPart(r, document)) .Where(p => p.Character != null) .ToArray(); GenerateHits(b, services, document); }