diff --git a/CHANGELOG.md b/CHANGELOG.md index 1adc56ff0..55230bb57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. - [#1829] Adding extra pixel to the width and height when rendering items (for example to AVI) - [#1828] Zero scale layer matrices support - [#1828] Incorrect stroke scaling (normal/none/vertical/horizontal) +- [#1771] DefineShape4 line filled using single color ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. @@ -2392,6 +2393,7 @@ All notable changes to this project will be documented in this file. [#1847]: https://www.free-decompiler.com/flash/issues/1847 [#1829]: https://www.free-decompiler.com/flash/issues/1829 [#1828]: https://www.free-decompiler.com/flash/issues/1828 +[#1771]: https://www.free-decompiler.com/flash/issues/1771 [#270]: https://www.free-decompiler.com/flash/issues/270 [#1718]: https://www.free-decompiler.com/flash/issues/1718 [#1801]: https://www.free-decompiler.com/flash/issues/1801 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index 1b8e3185a..25c393442 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -231,6 +231,7 @@ import com.jpexs.decompiler.flash.types.FOCALGRADIENT; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.GRADIENT; import com.jpexs.decompiler.flash.types.GRADRECORD; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.KERNINGRECORD; import com.jpexs.decompiler.flash.types.LANGCODE; import com.jpexs.decompiler.flash.types.LINESTYLE; @@ -2794,9 +2795,9 @@ public class SWFInputStream implements AutoCloseable { ret.lineStyles[i] = readLINESTYLE(shapeNum, "lineStyle"); } } else { - ret.lineStyles = new LINESTYLE2[lineStyleCount]; + ret.lineStyles2 = new LINESTYLE2[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readLINESTYLE2(shapeNum, "lineStyle"); + ret.lineStyles2[i] = readLINESTYLE2(shapeNum, "lineStyle"); } } endDumpLevel(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 94789ef80..6f1a6ed85 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.amf.amf3.Amf3OutputStream; @@ -1348,10 +1349,10 @@ public class SWFOutputStream extends OutputStream { writeUI8(lineStyleCount); } for (int i = 0; i < lineStyleCount; i++) { - writeLINESTYLE(value.lineStyles[i], shapeNum); + writeLINESTYLE((LINESTYLE) value.lineStyles[i], shapeNum); } } else { - lineStyleCount = value.lineStyles.length; + lineStyleCount = value.lineStyles2.length; if (lineStyleCount >= 0xff) { writeUI8(0xff); writeUI16(lineStyleCount); @@ -1359,7 +1360,7 @@ public class SWFOutputStream extends OutputStream { writeUI8(lineStyleCount); } for (int i = 0; i < lineStyleCount; i++) { - writeLINESTYLE2((LINESTYLE2) value.lineStyles[i], shapeNum); + writeLINESTYLE2((LINESTYLE2) value.lineStyles2[i], shapeNum); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java index a0898ed53..f93a127d6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters; import com.google.typography.font.sfntly.Font; @@ -193,7 +194,7 @@ public class FontExporter { char c = t.glyphToChar(i); SHAPE s = shapes.get(i); final List contours = new ArrayList<>(); - PathExporter seb = new PathExporter(swf, s, null) { + PathExporter seb = new PathExporter(1, swf, s, null) { private double transformX(double x) { return Math.ceil((double) (x / divider)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java index 31c01bbb0..178bb5ebc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -93,41 +93,41 @@ public class MorphShapeExporter { switch (settings.mode) { case SVG: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - ExportRectangle rect = new ExportRectangle(mst.getRect()); - rect.xMax *= settings.zoom; - rect.yMax *= settings.zoom; - rect.xMin *= settings.zoom; - rect.yMin *= settings.zoom; - SVGExporter exporter = new SVGExporter(rect, settings.zoom); - mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } - break; + ExportRectangle rect = new ExportRectangle(mst.getRect()); + rect.xMax *= settings.zoom; + rect.yMax *= settings.zoom; + rect.xMin *= settings.zoom; + rect.yMin *= settings.zoom; + SVGExporter exporter = new SVGExporter(rect, settings.zoom); + mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); + } + break; case CANVAS: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin); - int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin); - CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY); - cse.export(); - Set needed = new HashSet<>(); - CharacterTag ct = ((CharacterTag) mst); - needed.add(ct.getCharacterId()); - ct.getNeededCharactersDeep(needed); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWF.libraryToHtmlCanvas(ct.getSwf(), needed, baos); - fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(mst) + mst.getCharacterId(), mst.getRect()))); - } - break; + int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin); + int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin); + CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(mst.getShapeNum(), ((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY); + cse.export(); + Set needed = new HashSet<>(); + CharacterTag ct = ((CharacterTag) mst); + needed.add(ct.getCharacterId()); + ct.getNeededCharactersDeep(needed); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWF.libraryToHtmlCanvas(ct.getSwf(), needed, baos); + fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(mst) + mst.getCharacterId(), mst.getRect()))); + } + break; case SWF: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - try { - new PreviewExporter().exportSwf(fos, mst, null, 0, false); - } catch (ActionParseException ex) { - Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex); - } + try { + new PreviewExporter().exportSwf(fos, mst, null, 0, false); + } catch (ActionParseException ex) { + Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex); } + } - break; + break; } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java index 17a5f7d7d..11bd16248 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -96,16 +96,16 @@ public class ShapeExporter { switch (settings.mode) { case SVG: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - ExportRectangle rect = new ExportRectangle(st.getRect()); - rect.xMax *= settings.zoom; - rect.yMax *= settings.zoom; - rect.xMin *= settings.zoom; - rect.yMin *= settings.zoom; - SVGExporter exporter = new SVGExporter(rect, settings.zoom); - st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } - break; + ExportRectangle rect = new ExportRectangle(st.getRect()); + rect.xMax *= settings.zoom; + rect.yMax *= settings.zoom; + rect.xMin *= settings.zoom; + rect.yMin *= settings.zoom; + SVGExporter exporter = new SVGExporter(rect, settings.zoom); + st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); + } + break; case PNG: case BMP: RECT rect = st.getRect(); @@ -132,29 +132,29 @@ public class ShapeExporter { break; case CANVAS: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - SHAPE shp = st.getShapes(); - int deltaX = -shp.getBounds().Xmin; - int deltaY = -shp.getBounds().Ymin; - CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); - cse.export(); - Set needed = new HashSet<>(); - needed.add(st.getCharacterId()); - st.getNeededCharactersDeep(needed); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWF.libraryToHtmlCanvas(st.getSwf(), needed, baos); - fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(st) + st.getCharacterId(), st.getRect()))); - } - break; + SHAPE shp = st.getShapes(); + int deltaX = -shp.getBounds().Xmin; + int deltaY = -shp.getBounds().Ymin; + CanvasShapeExporter cse = new CanvasShapeExporter(st.getShapeNum(), null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); + cse.export(); + Set needed = new HashSet<>(); + needed.add(st.getCharacterId()); + st.getNeededCharactersDeep(needed); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWF.libraryToHtmlCanvas(st.getSwf(), needed, baos); + fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(st) + st.getCharacterId(), st.getRect()))); + } + break; case SWF: try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - try { - new PreviewExporter().exportSwf(fos, st, null, 0, false); - } catch (ActionParseException ex) { - Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex); - } + try { + new PreviewExporter().exportSwf(fos, st, null, 0, false); + } catch (ActionParseException ex) { + Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex); } + } - break; + break; } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/LineStyle.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/LineStyle.java index 837c71152..1a3a098d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/LineStyle.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/LineStyle.java @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.commonshape; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.RGB; @@ -51,12 +53,12 @@ public class LineStyle { public FillStyle fillType; - public LineStyle(LINESTYLE lineStyle) { - width = lineStyle.width; - color = lineStyle.color; - isLineStyle2 = lineStyle instanceof LINESTYLE2; - if (isLineStyle2) { - LINESTYLE2 lineStyle2 = (LINESTYLE2) lineStyle; + public LineStyle(ILINESTYLE ilineStyle) { + width = ilineStyle.getWidth(); + color = ilineStyle.getColor(); + if (ilineStyle.getNum() == 2) { + LINESTYLE2 lineStyle2 = (LINESTYLE2) ilineStyle; + isLineStyle2 = true; noHScaleFlag = lineStyle2.noHScaleFlag; noVScaleFlag = lineStyle2.noVScaleFlag; pixelHintingFlag = lineStyle2.pixelHintingFlag; @@ -69,4 +71,9 @@ public class LineStyle { fillType = lineStyle2.fillType == null ? null : new FillStyle(lineStyle2.fillType); } } + + public LineStyle(LINESTYLE lineStyle) { + + isLineStyle2 = false; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/CanvasMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/CanvasMorphShapeExporter.java index 6e4dd62ac..808c1f9cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/CanvasMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/CanvasMorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; @@ -85,8 +86,8 @@ public class CanvasMorphShapeExporter extends MorphShapeExporterBase { protected int fillHeight; - public CanvasMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double unitDivisor, int deltaX, int deltaY) { - super(shape, endShape, colorTransform); + public CanvasMorphShapeExporter(int morphShapeNum, SWF swf, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double unitDivisor, int deltaX, int deltaY) { + super(morphShapeNum, shape, endShape, colorTransform); this.deltaX = deltaX; this.deltaY = deltaY; this.unitDivisor = unitDivisor; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java index ea388f51b..186d3b983 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; @@ -40,8 +41,8 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas protected double zoom; - public DefaultSVGMorphShapeExporter(SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double zoom) { - super(shape, endShape, colorTransform); + public DefaultSVGMorphShapeExporter(int morphShapeNum, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double zoom) { + super(morphShapeNum, shape, endShape, colorTransform); this.zoom = zoom; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java index 665392809..55aeae2f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java @@ -12,13 +12,15 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.RGB; @@ -49,11 +51,11 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { protected List _fillStyles; - protected List _lineStyles; + protected List _lineStyles; protected List _fillStylesEnd; - protected List _lineStylesEnd; + protected List _lineStylesEnd; protected List>> _fillEdgeMaps; @@ -63,7 +65,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { protected ColorTransform colorTransform; - public MorphShapeExporterBase(SHAPE shape, SHAPE endShape, ColorTransform colorTransform) { + public MorphShapeExporterBase(int morphShapeNum, SHAPE shape, SHAPE endShape, ColorTransform colorTransform) { this.shape = shape; this.shapeEnd = endShape; this.colorTransform = colorTransform; @@ -72,14 +74,22 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { if (shape instanceof SHAPEWITHSTYLE) { SHAPEWITHSTYLE shapeWithStyle = (SHAPEWITHSTYLE) shape; _fillStyles.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles)); - _lineStyles.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles)); + if (morphShapeNum == 2) { + _lineStyles.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles2)); + } else { + _lineStyles.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles)); + } } _fillStylesEnd = new ArrayList<>(); _lineStylesEnd = new ArrayList<>(); if (endShape instanceof SHAPEWITHSTYLE) { SHAPEWITHSTYLE shapeWithStyle = (SHAPEWITHSTYLE) endShape; _fillStylesEnd.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles)); - _lineStylesEnd.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles)); + if (morphShapeNum == 2) { + _lineStylesEnd.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles2)); + } else { + _lineStylesEnd.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles)); + } } } @@ -102,8 +112,8 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { endShape(); } - protected void createEdgeMaps(List fillStyles, List lineStyles, - List fillStylesEnd, List lineStylesEnd, + protected void createEdgeMaps(List fillStyles, List lineStyles, + List fillStylesEnd, List lineStylesEnd, List>> fillEdgeMaps, List>> lineEdgeMaps) { if (!edgeMapsCreated) { int xPos = 0; @@ -383,8 +393,8 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { lineStyleIdx = e.getLineStyleIdx(); posX = Integer.MAX_VALUE; posY = Integer.MAX_VALUE; - LINESTYLE lineStyle = null; - LINESTYLE lineStyleEnd = null; + ILINESTYLE lineStyle = null; + ILINESTYLE lineStyleEnd = null; try { lineStyle = _lineStyles.get(lineStyleIdx - 1); lineStyleEnd = _lineStylesEnd.get(lineStyleIdx - 1); @@ -415,10 +425,10 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { hasFillFlag = lineStyle2.hasFillFlag; } lineStyle( - lineStyle.width, - lineStyleEnd.width, - colorTransform == null ? lineStyle.color : colorTransform.apply(lineStyle.color), - colorTransform == null ? lineStyleEnd.color : colorTransform.apply(lineStyleEnd.color), + lineStyle.getWidth(), + lineStyleEnd.getWidth(), + colorTransform == null ? lineStyle.getColor() : colorTransform.apply(lineStyle.getColor()), + colorTransform == null ? lineStyleEnd.getColor() : colorTransform.apply(lineStyleEnd.getColor()), pixelHintingFlag, scaleMode, startCapStyle, @@ -567,7 +577,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter { v1.addAll(Arrays.asList(v2)); } - protected void appendLineStyles(List v1, LINESTYLE[] v2) { + protected void appendLineStyles(List v1, ILINESTYLE[] v2) { v1.addAll(Arrays.asList(v2)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java index bd7c95772..ffd089b3a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; @@ -51,8 +52,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { private final SVGExporter exporter; - public SVGMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { - super(shape, endShape, colorTransform, zoom); + public SVGMorphShapeExporter(int morphShapeNum, SWF swf, SHAPE shape, SHAPE endShape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { + super(morphShapeNum, shape, endShape, colorTransform, zoom); this.swf = swf; this.id = id; this.defaultColor = defaultColor; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index be5faedf6..e1626f1b9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java @@ -154,13 +154,13 @@ public class BitmapExporter extends ShapeExporterBase { } } - public static void export(SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) { - BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor, colorTransform); + public static void export(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) { + BitmapExporter exporter = new BitmapExporter(shapeNum, swf, shape, defaultColor, colorTransform); exporter.exportTo(image, transformation, strokeTransformation, scaleStrokes); } - private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) { - super(swf, shape, colorTransform); + private BitmapExporter(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) { + super(shapeNum, swf, shape, colorTransform); this.swf = swf; this.defaultColor = defaultColor; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java index f1f346b31..70bb4f5e3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java @@ -149,8 +149,8 @@ public class CanvasShapeExporter extends ShapeExporterBase { return shapeData.toString(); } - public CanvasShapeExporter(RGB basicFill, double unitDivisor, SWF swf, SHAPE shape, ColorTransform colorTransform, int deltaX, int deltaY) { - super(swf, shape, colorTransform); + public CanvasShapeExporter(int shapeNum, RGB basicFill, double unitDivisor, SWF swf, SHAPE shape, ColorTransform colorTransform, int deltaX, int deltaY) { + super(shapeNum, swf, shape, colorTransform); this.swf = swf; this.unitDivisor = unitDivisor; this.basicFill = basicFill; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java index a15f0a32b..06216712f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; @@ -38,8 +39,8 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase { protected double zoom; - public DefaultSVGShapeExporter(SWF swf, SHAPE shape, ColorTransform colorTransform, double zoom) { - super(swf, shape, colorTransform); + public DefaultSVGShapeExporter(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform, double zoom) { + super(shapeNum, swf, shape, colorTransform); this.zoom = zoom; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java index a1b161b65..40f53db36 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java @@ -41,19 +41,19 @@ public class PathExporter extends ShapeExporterBase { private GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - public static List export(SWF swf, SHAPE shape) { - return export(swf, shape, new ArrayList<>()); + public static List export(int shapeNum, SWF swf, SHAPE shape) { + return export(shapeNum, swf, shape, new ArrayList<>()); } - public static List export(SWF swf, SHAPE shape, List strokes) { - PathExporter exporter = new PathExporter(swf, shape, null); + public static List export(int shapeNum, SWF swf, SHAPE shape, List strokes) { + PathExporter exporter = new PathExporter(shapeNum, swf, shape, null); exporter.export(); strokes.addAll(exporter.strokes); return exporter.paths; } - protected PathExporter(SWF swf, SHAPE shape, ColorTransform colorTransform) { - super(swf, shape, colorTransform); + protected PathExporter(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform) { + super(shapeNum, swf, shape, colorTransform); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java index f1ab00eb9..53ab58368 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java @@ -52,8 +52,8 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { private final SVGExporter exporter; - public SVGShapeExporter(SWF swf, SHAPE shape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { - super(swf, shape, colorTransform, zoom); + public SVGShapeExporter(int shapeNum, SWF swf, SHAPE shape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { + super(shapeNum, swf, shape, colorTransform, zoom); this.swf = swf; this.id = id; this.defaultColor = defaultColor; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java index 412096fb1..a9cc2bea2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.LineStyle; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.RGB; @@ -47,7 +48,7 @@ import java.util.Map; public abstract class ShapeExporterBase implements IShapeExporter { private static final boolean USE_REVERSE_LOOKUP = true; - + protected final SHAPE shape; private final List _fillStyles; @@ -60,7 +61,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { private final ColorTransform colorTransform; - public ShapeExporterBase(SWF swf, SHAPE shape, ColorTransform colorTransform) { + public ShapeExporterBase(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform) { this.shape = shape; this.colorTransform = colorTransform; @@ -75,8 +76,14 @@ public abstract class ShapeExporterBase implements IShapeExporter { fillStyles.add(new FillStyle(fillStyle)); } - for (LINESTYLE lineStyle : shapeWithStyle.lineStyles.lineStyles) { - lineStyles.add(new LineStyle(lineStyle)); + if (shapeNum <= 3) { + for (LINESTYLE lineStyle : shapeWithStyle.lineStyles.lineStyles) { + lineStyles.add(new LineStyle(lineStyle)); + } + } else { + for (LINESTYLE2 lineStyle : shapeWithStyle.lineStyles.lineStyles2) { + lineStyles.add(new LineStyle(lineStyle)); + } } } @@ -84,7 +91,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { List>> fillEdgeMaps = new ArrayList<>(); List>> lineEdgeMaps = new ArrayList<>(); try { - createEdgeMaps(shape, fillStyles, lineStyles, fillEdgeMaps, lineEdgeMaps); + createEdgeMaps(shapeNum, shape, fillStyles, lineStyles, fillEdgeMaps, lineEdgeMaps); } catch (Throwable t) { t.printStackTrace(); } @@ -124,7 +131,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { endShape(); } - private void createEdgeMaps(SHAPE shape, List fillStyles, List lineStyles, + private void createEdgeMaps(int shapeNum, SHAPE shape, List fillStyles, List lineStyles, List>> fillEdgeMaps, List>> lineEdgeMaps) { int xPos = 0; int yPos = 0; @@ -149,7 +156,11 @@ public abstract class ShapeExporterBase implements IShapeExporter { fillStyleIdxOffset = fillStyles.size(); lineStyleIdxOffset = lineStyles.size(); appendFillStyles(fillStyles, styleChangeRecord.fillStyles.fillStyles); - appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles); + if (shapeNum <= 3) { + appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles); + } else { + appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles2); + } } // Check if all styles are reset to 0. // This (probably) means that a new group starts with the next record @@ -374,9 +385,13 @@ public abstract class ShapeExporterBase implements IShapeExporter { miterLimitFactor = lineStyle.miterLimitFactor; hasFillFlag = lineStyle.hasFillFlag; } + RGB lineColor = lineStyle.color; + if (hasFillFlag && lineStyle.fillType.fillStyleType == FILLSTYLE.SOLID) { + lineColor = lineStyle.fillType.color; + } lineStyle( lineStyle.width, - colorTransform == null ? lineStyle.color : colorTransform.apply(lineStyle.color), + colorTransform == null ? lineColor : colorTransform.apply(lineColor), pixelHintingFlag, scaleMode, startCapStyle, @@ -613,6 +628,12 @@ public abstract class ShapeExporterBase implements IShapeExporter { } } + private void appendLineStyles(List v1, LINESTYLE2[] v2) { + for (LINESTYLE2 s : v2) { + v1.add(new LineStyle(s)); + } + } + private void appendEdges(List v1, List v2) { for (int i = 0; i < v2.size(); i++) { //System.err.println("appending " + v2.get(i)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java index 732cbc0de..1dcbd74d9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java @@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; import com.jpexs.decompiler.flash.types.GRADIENT; import com.jpexs.decompiler.flash.types.GRADRECORD; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; @@ -329,6 +330,7 @@ public class SvgImporter { showWarning(tagName + "tagNotSupported", "The SVG tag '" + tagName + "' is not supported."); } } + private void processSvgObject(Map idMap, int shapeNum, SHAPEWITHSTYLE shapes, Element element, Matrix transform, SvgStyle style) { for (int i = 0; i < element.getChildNodes().getLength(); i++) { Node childNode = element.getChildNodes().item(i); @@ -360,7 +362,7 @@ public class SvgImporter { newRecords.add(scrStyle); - LINESTYLE lineStyleObj = scrStyle.lineStyles.lineStyles.length < 1 ? null : scrStyle.lineStyles.lineStyles[0]; + ILINESTYLE lineStyleObj = scrStyle.lineStyles.lineStyles.length < 1 ? null : scrStyle.lineStyles.lineStyles[0]; LINESTYLE2 lineStyle2Obj = null; if (lineStyleObj instanceof LINESTYLE2) { lineStyle2Obj = (LINESTYLE2) lineStyleObj; @@ -1148,7 +1150,7 @@ public class SvgImporter { st = (DefineShape4Tag) (new SvgImporter().importSvg(st, svgDataS, false)); swf.addTag(st); SerializableImage si = new SerializableImage(480, 360, BufferedImage.TYPE_4BYTE_ABGR); - BitmapExporter.export(swf, st.shapes, Color.yellow, si, new Matrix(), new Matrix(), null, true); + BitmapExporter.export(st.getShapeNum(), swf, st.shapes, Color.yellow, si, new Matrix(), new Matrix(), null, true); List li = new ArrayList<>(); li.add(st); ImageIO.write(si.getBufferedImage(), "PNG", new File(name + ".imported.png")); @@ -1583,8 +1585,8 @@ public class SvgImporter { } SvgFill strokeFill = style.getStrokeFillWithOpacity(); if (strokeFill != null) { - if (scr.lineStyles.lineStyles.length > 0 && scr.lineStyles.lineStyles[0] instanceof LINESTYLE2) { - applyFillGradients(strokeFill, ((LINESTYLE2) scr.lineStyles.lineStyles[0]).fillType, bounds, scr, transform, shapeNum, style); + if (shapeNum == 4 && scr.lineStyles.lineStyles2.length > 0 && scr.lineStyles.lineStyles2[0] instanceof LINESTYLE2) { + applyFillGradients(strokeFill, ((LINESTYLE2) scr.lineStyles.lineStyles2[0]).fillType, bounds, scr, transform, shapeNum, style); } } } @@ -1619,10 +1621,9 @@ public class SvgImporter { if (strokeFill != null && strokeFill != SvgTransparentFill.INSTANCE) { Color lineColor = strokeFill.toColor(); - scr.lineStyles.lineStyles = new LINESTYLE[1]; - LINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2(); - lineStyle.color = getRGB(shapeNum, lineColor); - lineStyle.width = (int) Math.round(style.getStrokeWidth() * SWF.unitDivisor); + ILINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2(); + lineStyle.setColor(getRGB(shapeNum, lineColor)); + lineStyle.setWidth((int) Math.round(style.getStrokeWidth() * SWF.unitDivisor)); SvgLineCap lineCap = style.getStrokeLineCap(); SvgLineJoin lineJoin = style.getStrokeLineJoin(); if (lineStyle instanceof LINESTYLE2) { @@ -1643,6 +1644,8 @@ public class SvgImporter { : lineJoin == SvgLineJoin.BEVEL ? LINESTYLE2.BEVEL_JOIN : 0; lineStyle2.joinStyle = swfJoin; lineStyle2.miterLimitFactor = (float) style.getStrokeMiterLimit(); + scr.lineStyles.lineStyles2 = new LINESTYLE2[1]; + scr.lineStyles.lineStyles2[0] = lineStyle2; } else { if (lineCap != SvgLineCap.ROUND) { showWarning("lineCapNotSupported", "LineCap style not supported in shape " + shapeNum); @@ -1650,12 +1653,14 @@ public class SvgImporter { if (lineJoin != SvgLineJoin.ROUND) { showWarning("lineJoinNotSupported", "LineJoin style not supported in shape " + shapeNum); } + scr.lineStyles.lineStyles = new LINESTYLE[1]; + scr.lineStyles.lineStyles[0] = (LINESTYLE) lineStyle; } - scr.lineStyles.lineStyles[0] = lineStyle; scr.lineStyle = 1; } else { scr.lineStyles.lineStyles = new LINESTYLE[0]; + scr.lineStyles.lineStyles2 = new LINESTYLE2[0]; scr.lineStyle = 0; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 0c9464dc8..98cc17d13 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -434,7 +434,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag { @Override public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) { - SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), image, frame, Color.black, colorTransform); + SHAPERECORD.shapeListToImage(1, swf, getGlyphShapeTable(), image, frame, Color.black, colorTransform); } @Override @@ -451,7 +451,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag { String cs = "" + c; cs = cs.replace("\\", "\\\\").replace("\"", "\\\""); result.append("\t\tcase \"").append(cs).append("\":\r\n"); - CanvasShapeExporter exporter = new CanvasShapeExporter(null, unitDivisor, swf, shapes.get(i), null, 0, 0); + CanvasShapeExporter exporter = new CanvasShapeExporter(1, null, unitDivisor, swf, shapes.get(i), null, 0, 0); exporter.export(); result.append("\t\t").append(exporter.getShapeData().replaceAll("\r\n", "\r\n\t\t")); result.append("\tbreak;\r\n"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java index 5804446bf..c054c5b8f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java @@ -227,23 +227,23 @@ public abstract class ImageTag extends DrawableTag { @Override public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) { - return transformation.toTransform().createTransformedShape(getShape().getOutline(swf, stroked)); + return transformation.toTransform().createTransformedShape(getShape().getOutline(1, swf, stroked)); } @Override public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) { - BitmapExporter.export(swf, getShape(), null, image, transformation, strokeTransformation, colorTransform, true); + BitmapExporter.export(1, swf, getShape(), null, image, transformation, strokeTransformation, colorTransform, true); } @Override public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), getCharacterId(), exporter, null, colorTransform, 1); + SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, getShape(), getCharacterId(), exporter, null, colorTransform, 1); shapeExporter.export(); } @Override public void toHtmlCanvas(StringBuilder result, double unitDivisor) { - CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, getShape(), null, 0, 0); + CanvasShapeExporter cse = new CanvasShapeExporter(1, null, unitDivisor, swf, getShape(), null, 0, 0); cse.export(); result.append(cse.getShapeData()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java index 7ac72fd2e..d44aed8f0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java @@ -320,7 +320,7 @@ public abstract class MorphShapeTag extends DrawableTag { // todo: Currently the generated image is not cached, because the cache // key contains the hashCode of the finalRecord object, and it is always // recreated - BitmapExporter.export(swf, shape, null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); + BitmapExporter.export(getShapeNum() == 2 ? 4 : 1, swf, shape, null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); } @Override @@ -328,11 +328,11 @@ public abstract class MorphShapeTag extends DrawableTag { if (ratio == -2) { SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0); SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535); - SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, getCharacterId(), exporter, null, colorTransform, 1); + SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(getShapeNum(), swf, beginShapes, endShapes, getCharacterId(), exporter, null, colorTransform, 1); shapeExporter.export(); } else { SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, getCharacterId(), exporter, null, colorTransform, 1); + SVGShapeExporter shapeExporter = new SVGShapeExporter(getShapeNum() == 2 ? 4 : 1, swf, shapes, getCharacterId(), exporter, null, colorTransform, 1); shapeExporter.export(); } } @@ -350,12 +350,12 @@ public abstract class MorphShapeTag extends DrawableTag { @Override public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) { - return transformation.toTransform().createTransformedShape(getShapeAtRatio(ratio).getOutline(swf, stroked)); + return transformation.toTransform().createTransformedShape(getShapeAtRatio(ratio).getOutline(getShapeNum() == 2 ? 4 : 1, swf, stroked)); } @Override public void toHtmlCanvas(StringBuilder result, double unitDivisor) { - CanvasMorphShapeExporter cmse = new CanvasMorphShapeExporter(swf, getShapeAtRatio(0), getShapeAtRatio(MAX_RATIO), null, unitDivisor, 0, 0); + CanvasMorphShapeExporter cmse = new CanvasMorphShapeExporter(getShapeNum(), swf, getShapeAtRatio(0), getShapeAtRatio(MAX_RATIO), null, unitDivisor, 0, 0); cmse.export(); result.append(cmse.getShapeData()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java index e6d7dc0b7..dab3b67c3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.helpers.LazyObject; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; @@ -131,20 +132,19 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject { @Override public RECT getRectWithStrokes() { - int maxWidth = 0; - for (LINESTYLE ls : getShapes().lineStyles.lineStyles) { - if (ls.width > maxWidth) { - maxWidth = ls.width; + for (ILINESTYLE ls : getShapes().lineStyles.lineStyles) { + if (ls.getWidth() > maxWidth) { + maxWidth = ls.getWidth(); } } for (SHAPERECORD sr : getShapes().shapeRecords) { if (sr instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) sr; if (scr.stateNewStyles) { - for (LINESTYLE ls : scr.lineStyles.lineStyles) { - if (ls.width > maxWidth) { - maxWidth = ls.width; + for (ILINESTYLE ls : scr.lineStyles.lineStyles) { + if (ls.getWidth() > maxWidth) { + maxWidth = ls.getWidth(); } } } @@ -160,7 +160,6 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject { return r; } - @Override public int getUsedParameters() { return 0; @@ -168,14 +167,14 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject { @Override public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) { - return transformation.toTransform().createTransformedShape(getShapes().getOutline(swf, stroked)); + return transformation.toTransform().createTransformedShape(getShapes().getOutline(getShapeNum(), swf, stroked)); } @Override public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) { - BitmapExporter.export(swf, getShapes(), null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); + BitmapExporter.export(getShapeNum(), swf, getShapes(), null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); if (Configuration._debugMode.get()) { // show control points - List paths = PathExporter.export(swf, getShapes()); + List paths = PathExporter.export(getShapeNum(), swf, getShapes()); double[] coords = new double[6]; AffineTransform at = transformation.toTransform(); at.preConcatenate(AffineTransform.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); @@ -217,13 +216,13 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject { @Override public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), getCharacterId(), exporter, null, colorTransform, 1); + SVGShapeExporter shapeExporter = new SVGShapeExporter(getShapeNum(), swf, getShapes(), getCharacterId(), exporter, null, colorTransform, 1); shapeExporter.export(); } @Override public void toHtmlCanvas(StringBuilder result, double unitDivisor) { - CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, getShapes(), null, 0, 0); + CanvasShapeExporter cse = new CanvasShapeExporter(getShapeNum(), null, unitDivisor, swf, getShapes(), null, 0, 0); cse.export(); result.append(cse.getShapeData()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index a6ff69530..f6623f15a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -422,7 +422,7 @@ public abstract class TextTag extends DrawableTag { Graphics2D g = (Graphics2D) image.getGraphics(); Matrix mat = transformation.clone(); mat = mat.concatenate(new Matrix(textMatrix)); - BitmapExporter.export(swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, mat, colorTransform, true); + BitmapExporter.export(1, swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, mat, colorTransform, true); } public static void drawBorderHtmlCanvas(SWF swf, StringBuilder result, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double unitDivisor) { @@ -430,7 +430,7 @@ public abstract class TextTag extends DrawableTag { result.append("\tctx.save();\r\n"); result.append("\tctx.transform(").append(mat.scaleX).append(",").append(mat.rotateSkew0).append(",").append(mat.rotateSkew1).append(",").append(mat.scaleY).append(",").append(mat.translateX).append(",").append(mat.translateY).append(");\r\n"); SHAPE shape = getBorderShape(borderColor, fillColor, rect); - CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, shape, colorTransform, 0, 0); + CanvasShapeExporter cse = new CanvasShapeExporter(1, null, unitDivisor, swf, shape, colorTransform, 0, 0); cse.export(); result.append(cse.getShapeData()); result.append("\tctx.restore();\r\n"); @@ -439,7 +439,7 @@ public abstract class TextTag extends DrawableTag { public static void drawBorderSVG(SWF swf, SVGExporter exporter, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double zoom) { exporter.createSubGroup(new Matrix(textMatrix), null); SHAPE shape = getBorderShape(borderColor, fillColor, rect); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, 0, exporter, null, colorTransform, zoom); + SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, shape, 0, exporter, null, colorTransform, zoom); shapeExporter.export(); exporter.endGroup(); } @@ -512,7 +512,7 @@ public abstract class TextTag extends DrawableTag { } if (shape != null) { - BitmapExporter.export(swf, shape, textColor2, image, mat, mat, colorTransform, true); + BitmapExporter.export(1, swf, shape, textColor2, image, mat, mat, colorTransform, true); if (SHAPERECORD.DRAW_BOUNDING_BOX) { RGB borderColor = new RGBA(Color.black); RGB fillColor = new RGBA(new Color(255, 255, 255, 0)); @@ -756,7 +756,7 @@ public abstract class TextTag extends DrawableTag { if (charId == null) { charId = exporter.getUniqueId(Helper.getValidHtmlId("font_" + font.getFontNameIntag() + "_" + ch)); exporter.createDefGroup(null, charId); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, 0, exporter, null, colorTransform, zoom); + SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, shape, 0, exporter, null, colorTransform, zoom); shapeExporter.export(); if (!exporter.endGroup()) { charId = ""; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ILINESTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ILINESTYLE.java new file mode 100644 index 000000000..1565ea511 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/ILINESTYLE.java @@ -0,0 +1,23 @@ +package com.jpexs.decompiler.flash.types; + +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import com.jpexs.helpers.ConcreteClasses; +import java.io.Serializable; + +/** + * + * @author JPEXS + */ +@ConcreteClasses({LINESTYLE.class, LINESTYLE2.class}) +public interface ILINESTYLE extends NeedsCharacters, Serializable { + + public int getNum(); + + public RGB getColor(); + + public int getWidth(); + + public void setColor(RGB color); + + public void setWidth(int width); +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java index 1f73fadab..65d26015e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.tags.DefineShape3Tag; @@ -27,7 +28,7 @@ import java.util.Set; * * @author JPEXS */ -public class LINESTYLE implements NeedsCharacters, Serializable { +public class LINESTYLE implements NeedsCharacters, Serializable, ILINESTYLE { @SWFType(BasicType.UI16) public int width; @@ -48,4 +49,29 @@ public class LINESTYLE implements NeedsCharacters, Serializable { public boolean removeCharacter(int characterId) { return false; } + + @Override + public int getNum() { + return 1; + } + + @Override + public RGB getColor() { + return color; + } + + @Override + public int getWidth() { + return width; + } + + @Override + public void setColor(RGB color) { + this.color = color; + } + + @Override + public void setWidth(int width) { + this.width = width; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java index a1ce169f5..b4846856f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE2.java @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.EnumValue; import com.jpexs.decompiler.flash.types.annotations.Reserved; @@ -26,7 +28,10 @@ import java.util.Set; * * @author JPEXS */ -public class LINESTYLE2 extends LINESTYLE implements Serializable { +public class LINESTYLE2 implements NeedsCharacters, Serializable, ILINESTYLE { + + @SWFType(BasicType.UI16) + public int width; @SWFType(value = BasicType.UB, count = 2) @EnumValue(value = ROUND_CAP, text = "Round cap") @@ -76,6 +81,10 @@ public class LINESTYLE2 extends LINESTYLE implements Serializable { @Conditional(value = "joinStyle", options = {MITER_JOIN}) public float miterLimitFactor; + @Conditional(value = "!hasFillFlag") + public RGBA color; + + @Conditional(value = "hasFillFlag") public FILLSTYLE fillType; @Override @@ -100,4 +109,36 @@ public class LINESTYLE2 extends LINESTYLE implements Serializable { } return false; } + + @Override + public int getNum() { + return 2; + } + + @Override + public RGB getColor() { + if (hasFillFlag) { + return null; + } + return color; + } + + @Override + public int getWidth() { + return width; + } + + @Override + public void setColor(RGB color) { + if (color instanceof RGBA) { + this.color = (RGBA) color; + } + this.color = new RGBA(color.toColor()); + hasFillFlag = false; + } + + @Override + public void setWidth(int width) { + this.width = width; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java index eff237c81..15d58bb2b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLEARRAY.java @@ -12,10 +12,16 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; +import com.jpexs.decompiler.flash.tags.DefineShape2Tag; +import com.jpexs.decompiler.flash.tags.DefineShape3Tag; +import com.jpexs.decompiler.flash.tags.DefineShape4Tag; +import com.jpexs.decompiler.flash.tags.DefineShapeTag; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.SWFArray; import java.io.Serializable; import java.util.Set; @@ -27,11 +33,16 @@ import java.util.Set; public class LINESTYLEARRAY implements NeedsCharacters, Serializable { @SWFArray(value = "lineStyle") + @Conditional(tags = {DefineShapeTag.ID, DefineShape2Tag.ID, DefineShape3Tag.ID}) public LINESTYLE[] lineStyles = new LINESTYLE[0]; + @SWFArray(value = "lineStyle") + @Conditional(tags = {DefineShape4Tag.ID}) + public LINESTYLE2[] lineStyles2 = new LINESTYLE2[0]; + @Override public void getNeededCharacters(Set needed) { - for (LINESTYLE ls : lineStyles) { + for (ILINESTYLE ls : lineStyles) { ls.getNeededCharacters(needed); } } @@ -39,7 +50,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { @Override public boolean replaceCharacter(int oldCharacterId, int newCharacterId) { boolean modified = false; - for (LINESTYLE ls : lineStyles) { + for (ILINESTYLE ls : lineStyles) { modified |= ls.replaceCharacter(oldCharacterId, newCharacterId); } return modified; @@ -48,7 +59,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable { @Override public boolean removeCharacter(int characterId) { boolean modified = false; - for (LINESTYLE ls : lineStyles) { + for (ILINESTYLE ls : lineStyles) { modified |= ls.removeCharacter(characterId); } return modified; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLEARRAY.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLEARRAY.java index c4da1f9c4..16e8831ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLEARRAY.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MORPHLINESTYLEARRAY.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import java.io.Serializable; @@ -36,9 +37,9 @@ public class MORPHLINESTYLEARRAY implements Serializable { } } if (shapeNum == 2) { - ret.lineStyles = new LINESTYLE2[lineStyles2.length]; + ret.lineStyles2 = new LINESTYLE2[lineStyles2.length]; for (int m = 0; m < lineStyles2.length; m++) { - ret.lineStyles[m] = lineStyles2[m].getLineStyle2At(ratio); + ret.lineStyles2[m] = lineStyles2[m].getLineStyle2At(ratio); } } return ret; @@ -53,9 +54,9 @@ public class MORPHLINESTYLEARRAY implements Serializable { } } if (shapeNum == 2) { - ret.lineStyles = new LINESTYLE2[lineStyles2.length]; + ret.lineStyles2 = new LINESTYLE2[lineStyles2.length]; for (int m = 0; m < lineStyles2.length; m++) { - ret.lineStyles[m] = lineStyles2[m].getStartLineStyle2(); + ret.lineStyles2[m] = lineStyles2[m].getStartLineStyle2(); } } return ret; @@ -70,9 +71,9 @@ public class MORPHLINESTYLEARRAY implements Serializable { } } if (shapeNum == 2) { - ret.lineStyles = new LINESTYLE2[lineStyles2.length]; + ret.lineStyles2 = new LINESTYLE2[lineStyles2.length]; for (int m = 0; m < lineStyles2.length; m++) { - ret.lineStyles[m] = lineStyles2[m].getEndLineStyle2(); + ret.lineStyles2[m] = lineStyles2[m].getEndLineStyle2(); } } return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java index 6883941cc..f1fcda392 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.SWF; @@ -76,13 +77,13 @@ public class SHAPE implements NeedsCharacters, Serializable { return SHAPERECORD.getBounds(shapeRecords); } - public Shape getOutline(SWF swf, boolean stroked) { + public Shape getOutline(int shapeNum, SWF swf, boolean stroked) { if (cachedOutline != null) { return cachedOutline; } List strokes = new ArrayList<>(); - List paths = PathExporter.export(swf, this, strokes); + List paths = PathExporter.export(shapeNum, swf, this, strokes); Area area = new Area(); for (GeneralPath path : paths) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java index b699d9929..cc778ac11 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; @@ -91,7 +92,7 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab if (shapeNum <= 3) { ret.lineStyles.lineStyles = new LINESTYLE[0]; } else { - ret.lineStyles.lineStyles = new LINESTYLE2[0]; + ret.lineStyles.lineStyles2 = new LINESTYLE2[0]; } return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java index 96647bf6e..7fa83aea3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.types.annotations.parser; import com.jpexs.decompiler.flash.types.annotations.Conditional; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index bfe075dbf..e466cff61 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -138,7 +138,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali return ret; } - public static void shapeListToImage(SWF swf, List shapes, SerializableImage image, int frame, Color color, ColorTransform colorTransform) { + public static void shapeListToImage(int shapeNum, SWF swf, List shapes, SerializableImage image, int frame, Color color, ColorTransform colorTransform) { if (shapes.isEmpty()) { return; } @@ -219,7 +219,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali Matrix transformation = Matrix.getTranslateInstance(px, py); transformation.scale(ratio); - BitmapExporter.export(swf, shape, color, image, transformation, transformation, colorTransform, true); + BitmapExporter.export(shapeNum, swf, shape, color, image, transformation, transformation, colorTransform, true); // draw bounding boxes if (DRAW_BOUNDING_BOX) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 9db8e975e..e36225207 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -102,6 +102,7 @@ import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; import com.jpexs.decompiler.flash.types.GRADIENT; import com.jpexs.decompiler.flash.types.GRADRECORD; +import com.jpexs.decompiler.flash.types.ILINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE; import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; @@ -253,7 +254,7 @@ public class XFLConverter { } } - private static String getScaleMode(LINESTYLE lineStyle) { + private static String getScaleMode(ILINESTYLE lineStyle) { if (lineStyle instanceof LINESTYLE2) { LINESTYLE2 ls2 = (LINESTYLE2) lineStyle; if (ls2.noHScaleFlag && ls2.noVScaleFlag) { @@ -270,16 +271,16 @@ public class XFLConverter { return "normal"; } - private static void convertLineStyle(LINESTYLE ls, int shapeNum, XFLXmlWriter writer) throws XMLStreamException { + private static void convertLineStyle(ILINESTYLE ls, int shapeNum, XFLXmlWriter writer) throws XMLStreamException { writer.writeStartElement("SolidStroke", new String[]{ "scaleMode", getScaleMode(ls), - "weight", Double.toString(((float) ls.width) / SWF.unitDivisor),}); + "weight", Double.toString(((float) ls.getWidth()) / SWF.unitDivisor),}); writer.writeStartElement("fill"); if (!(ls instanceof LINESTYLE2) || !((LINESTYLE2) ls).hasFillFlag) { - writer.writeStartElement("SolidColor", new String[]{"color", ls.color.toHexRGB()}); + writer.writeStartElement("SolidColor", new String[]{"color", ls.getColor().toHexRGB()}); if (shapeNum >= 3) { - writer.writeAttribute("alpha", ((RGBA) ls.color).getAlphaFloat()); + writer.writeAttribute("alpha", ((RGBA) ls.getColor()).getAlphaFloat()); } writer.writeEndElement(); @@ -763,10 +764,10 @@ public class XFLConverter { strokesStr.writeEndElement(); lineStyleCount++; } - } else if (lineStyles.lineStyles != null) { - for (int l = 0; l < lineStyles.lineStyles.length; l++) { + } else if (lineStyles.lineStyles2 != null) { + for (int l = 0; l < lineStyles.lineStyles2.length; l++) { strokesStr.writeStartElement("StrokeStyle", new String[]{"index", Integer.toString(lineStyleCount + 1)}); - convertLineStyle(characters, (LINESTYLE2) lineStyles.lineStyles[l], shapeNum, strokesStr); + convertLineStyle(characters, (LINESTYLE2) lineStyles.lineStyles2[l], shapeNum, strokesStr); strokesStr.writeEndElement(); lineStyleCount++; } @@ -815,8 +816,8 @@ public class XFLConverter { if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) { if (shapeNum == 4) { if (strokeStyleOrig > 0) { - if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) { - RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color; + if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) { + RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor(); if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) { empty = true; } @@ -871,9 +872,9 @@ public class XFLConverter { lineStyleCount++; } } else { - for (int l = 0; l < scr.lineStyles.lineStyles.length; l++) { + for (int l = 0; l < scr.lineStyles.lineStyles2.length; l++) { strokesNewStr.writeStartElement("StrokeStyle", new String[]{"index", Integer.toString(lineStyleCount + 1)}); - convertLineStyle(characters, (LINESTYLE2) scr.lineStyles.lineStyles[l], shapeNum, strokesNewStr); + convertLineStyle(characters, (LINESTYLE2) scr.lineStyles.lineStyles2[l], shapeNum, strokesNewStr); strokesNewStr.writeEndElement(); lineStyleCount++; } @@ -914,8 +915,8 @@ public class XFLConverter { if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) { if (shapeNum == 4) { if (strokeStyleOrig > 0) { - if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) { - RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color; + if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) { + RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor(); if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) { empty = true; } @@ -958,8 +959,8 @@ public class XFLConverter { if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) { if (shapeNum == 4) { if (strokeStyleOrig > 0) { - if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) { - RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color; + if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) { + RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor(); if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) { empty = true; } @@ -3011,7 +3012,6 @@ public class XFLConverter { if (hasClipDepth) { continue; }*/ - boolean nonEmpty = writeLayer(index, depthToFramesList.get(d), d, 0, Integer.MAX_VALUE, -1, writer, nonLibraryShapes, tags, timelineTags, characters, flaVersion, files); if (nonEmpty) { index++; diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics.swf b/libsrc/ffdec_lib/testdata/graphics/graphics.swf index 7a3847f16..89e39af64 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics.swf and b/libsrc/ffdec_lib/testdata/graphics/graphics.swf differ diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml index a0d00fad4..71dd2e256 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml @@ -1,7 +1,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -59,9 +59,9 @@ - + - + @@ -74,7 +74,7 @@ }]]> - + @@ -175,7 +175,7 @@ - + @@ -787,10 +787,10 @@ !3980 1990|2980 1990!2980 1990|2980 990!2980 990|3980 990!3980 990|3980 1990"/> - + @@ -1389,18 +1389,18 @@ - + - - + + @@ -2273,7 +2273,7 @@ - + @@ -2286,7 +2286,7 @@ - + @@ -2325,6 +2325,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2952,7 +2990,7 @@ - + @@ -3753,6 +3791,23 @@ + + + + + + + + + 066 Antialiasing + + + + + + + + @@ -3760,6 +3815,8 @@ + + @@ -3778,7 +3835,5 @@ - - \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml index a0a61f94e..b5f1515aa 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml @@ -28,91 +28,149 @@ - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml index 21fc928b6..e775eccfa 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml @@ -25,9 +25,9 @@ - - + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml index a1c282459..38aa00fed 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml @@ -28,75 +28,71 @@ - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + - - - - - - - - + - - - - - - + + + + + + + + + + + + - + + + + + - - + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml index 17cdfa5a8..e49e344b5 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml @@ -5,8 +5,8 @@ xmlns:xmp="http://ns.adobe.com/xap/1.0/"> Adobe Flash Professional CS6 - build 481 2021-03-14T08:29:20+01:00 - 2022-10-23T21:46:13-07:00 - 2022-10-23T21:46:13-07:00 + 2022-10-24T11:04:44-07:00 + 2022-10-24T11:04:44-07:00 @@ -15,7 +15,7 @@ - xmp.iid:31A9D48A0F53ED11A79581A4DE002270 + xmp.iid:CFDFDAC26B53ED11A79581A4DE002270 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 @@ -128,6 +128,12 @@ 2021-03-14T08:29:20+01:00 Adobe Flash Professional CS6 - build 481 + + created + xmp.iid:CFDFDAC26B53ED11A79581A4DE002270 + 2021-03-14T08:29:20+01:00 + Adobe Flash Professional CS6 - build 481 + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache index 0ccc70031..758948b5e 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache and b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache differ