public IImage[] GetImages() { ListSet <IImage> images = new ListSet <IImage>(); if (this.StartShape == null || this.EndShape == null) { return(new IImage[0]); } foreach (ShapeDef sd in new ShapeDef[] { this.StartShape, this.EndShape }) { foreach (IFillStyle fs in sd.FillStyles) { if (fs.Bitmap != null) { images.AddIfNotAlredy(fs.Bitmap); } } foreach (IShapeRecord sr in sd.Records) { if (sr is StyleChange) { StyleChange sc = (StyleChange)sr; IFillStyle fs = sc.FillStyle0; if (fs != null && fs.Bitmap != null) { images.AddIfNotAlredy(fs.Bitmap); } fs = sc.FillStyle1; if (fs != null && fs.Bitmap != null) { images.AddIfNotAlredy(fs.Bitmap); } } } } return(images.ToArray()); }
private void ReadShapeRecordsInto(ShapeDef sws, SWFDataTypeReader shapeReader, ref int fillBits, ref int lineBits, Tag format) { List <IShapeRecord> records = new List <IShapeRecord>(); int currentX = 0; int currentY = 0; while (true) { bool isEdgeRecord = shapeReader.ReadBit(); if (isEdgeRecord) { if (shapeReader.ReadBit()) { /* StraightEdgeRecord */ int bpv = 2 + (int)shapeReader.ReadUBits(4); bool isGeneralLine = shapeReader.ReadBit(); bool isVertical = false; if (!isGeneralLine) { isVertical = shapeReader.ReadBit(); } int dx = 0; int dy = 0; if (isGeneralLine || !isVertical) { dx = shapeReader.ReadSBits(bpv); } if (isGeneralLine || isVertical) { dy = shapeReader.ReadSBits(bpv); } currentX += dx; currentY += dx; records.Add(new StraightEdge() { DX = dx, DY = dy }); } else { /* CurvedEdgeRecord */ int bpv = 2 + (int)shapeReader.ReadUBits(4); int ctrlDX = shapeReader.ReadSBits(bpv); int ctrlDY = shapeReader.ReadSBits(bpv); int anchorDX = shapeReader.ReadSBits(bpv); int anchorDY = shapeReader.ReadSBits(bpv); currentX += ctrlDX + anchorDX; currentY += ctrlDY + anchorDY; records.Add(new CurvedEdge() { AnchorDX = anchorDX, AnchorDY = anchorDY, CtrlDX = ctrlDX, CtrlDY = ctrlDY }); } } else { uint flags = shapeReader.ReadUBits(5); if (flags == 0) { /* EndShapeRecord */ break; } /* StyleChangeRecord */ bool stateMoveTo = (flags & 1) == 1; flags >>= 1; bool stateFillStyle0 = (flags & 1) == 1; flags >>= 1; bool stateFillStyle1 = (flags & 1) == 1; flags >>= 1; bool stateLineStyle = (flags & 1) == 1; flags >>= 1; bool stateNewStyles = (flags & 1) == 1; flags >>= 1; StyleChange sc = new StyleChange(); if (stateMoveTo) { int moveBits = (int)shapeReader.ReadUBits(5); sc.DX = shapeReader.ReadSBits(moveBits); sc.DY = shapeReader.ReadSBits(moveBits); currentX = sc.DX.Value; currentY = sc.DY.Value; } if (stateFillStyle0) { sc.FillStyle0 = sws.FillFromIndex((int)shapeReader.ReadUBits(fillBits)); } if (stateFillStyle1) { sc.FillStyle1 = sws.FillFromIndex((int)shapeReader.ReadUBits(fillBits)); } if (stateLineStyle) { sc.LineStyle = (int)shapeReader.ReadUBits(lineBits); } if (stateNewStyles) { sc.NewFillStyles = this.ReadFillStyleArray(shapeReader, format); sc.NewLineStyles = this.ReadLineStyleArray(shapeReader, format); fillBits = (int)shapeReader.ReadUBits(4); lineBits = (int)shapeReader.ReadUBits(4); /* ISSUE 21: We're storing new styles defined in shape records in two places and * in such a way that we can't figure out where we got them from. This makes * it impossible to reconstruct the SWF data. Kinda need to work out how to * find styles. */ sws.FillStyles.AddRange(sc.NewFillStyles); sws.LineStyles.AddRange(sc.NewLineStyles); } records.Add(sc); } } shapeReader.Align8(); sws.Records = records.ToArray(); }
private void ReadShapeRecordsInto(ShapeDef sws, SWFDataTypeReader shapeReader, ref int fillBits, ref int lineBits, Tag format) { List<IShapeRecord> records = new List<IShapeRecord>(); int currentX = 0; int currentY = 0; while (true) { bool isEdgeRecord = shapeReader.ReadBit(); if (isEdgeRecord) { if (shapeReader.ReadBit()) { /* StraightEdgeRecord */ int bpv = 2 + (int)shapeReader.ReadUBits(4); bool isGeneralLine = shapeReader.ReadBit(); bool isVertical = false; if (!isGeneralLine) { isVertical = shapeReader.ReadBit(); } int dx = 0; int dy = 0; if (isGeneralLine || !isVertical) { dx = shapeReader.ReadSBits(bpv); } if (isGeneralLine || isVertical) { dy = shapeReader.ReadSBits(bpv); } currentX += dx; currentY += dx; records.Add(new StraightEdge() { DX = dx, DY = dy }); } else { /* CurvedEdgeRecord */ int bpv = 2 + (int)shapeReader.ReadUBits(4); int ctrlDX = shapeReader.ReadSBits(bpv); int ctrlDY = shapeReader.ReadSBits(bpv); int anchorDX = shapeReader.ReadSBits(bpv); int anchorDY = shapeReader.ReadSBits(bpv); currentX += ctrlDX + anchorDX; currentY += ctrlDY + anchorDY; records.Add(new CurvedEdge() { AnchorDX = anchorDX, AnchorDY = anchorDY, CtrlDX = ctrlDX, CtrlDY = ctrlDY }); } } else { uint flags = shapeReader.ReadUBits(5); if (flags == 0) { /* EndShapeRecord */ break; } /* StyleChangeRecord */ bool stateMoveTo = (flags & 1) == 1; flags >>= 1; bool stateFillStyle0 = (flags & 1) == 1; flags >>= 1; bool stateFillStyle1 = (flags & 1) == 1; flags >>= 1; bool stateLineStyle = (flags & 1) == 1; flags >>= 1; bool stateNewStyles = (flags & 1) == 1; flags >>= 1; StyleChange sc = new StyleChange(); if (stateMoveTo) { int moveBits = (int)shapeReader.ReadUBits(5); sc.DX = shapeReader.ReadSBits(moveBits); sc.DY = shapeReader.ReadSBits(moveBits); currentX = sc.DX.Value; currentY = sc.DY.Value; } if (stateFillStyle0) { sc.FillStyle0 = sws.FillFromIndex((int)shapeReader.ReadUBits(fillBits)); } if (stateFillStyle1) { sc.FillStyle1 = sws.FillFromIndex((int)shapeReader.ReadUBits(fillBits)); } if (stateLineStyle) { sc.LineStyle = (int)shapeReader.ReadUBits(lineBits); } if (stateNewStyles) { sc.NewFillStyles = this.ReadFillStyleArray(shapeReader, format); sc.NewLineStyles = this.ReadLineStyleArray(shapeReader, format); fillBits = (int)shapeReader.ReadUBits(4); lineBits = (int)shapeReader.ReadUBits(4); /* ISSUE 21: We're storing new styles defined in shape records in two places and * in such a way that we can't figure out where we got them from. This makes * it impossible to reconstruct the SWF data. Kinda need to work out how to * find styles. */ sws.FillStyles.AddRange(sc.NewFillStyles); sws.LineStyles.AddRange(sc.NewLineStyles); } records.Add(sc); } } shapeReader.Align8(); sws.Records = records.ToArray(); }