diff --git a/CHANGELOG.md b/CHANGELOG.md index 55230bb57..bc5e32262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file. - [#1828] Zero scale layer matrices support - [#1828] Incorrect stroke scaling (normal/none/vertical/horizontal) - [#1771] DefineShape4 line filled using single color +- Minimum stroke width should be 1 px ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. 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 1e46e0b57..546fd7cce 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 @@ -97,7 +97,7 @@ public class BitmapExporter extends ShapeExporterBase { private double thicknessScaleX; private double thicknessScaleY; - private double realZoom; + private double unzoom; private static boolean linearGradientColorWarnignShown = false; @@ -154,9 +154,9 @@ public class BitmapExporter extends ShapeExporterBase { } } - public static void export(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) { + public static void export(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, double unzoom, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) { BitmapExporter exporter = new BitmapExporter(shapeNum, swf, shape, defaultColor, colorTransform); - exporter.exportTo(image, transformation, strokeTransformation, scaleStrokes); + exporter.exportTo(image, unzoom, transformation, strokeTransformation, scaleStrokes); } private BitmapExporter(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) { @@ -165,7 +165,7 @@ public class BitmapExporter extends ShapeExporterBase { this.defaultColor = defaultColor; } - private void exportTo(SerializableImage image, Matrix transformation, Matrix strokeTransformation, boolean scaleStrokes) { + private void exportTo(SerializableImage image, double unzoom, Matrix transformation, Matrix strokeTransformation, boolean scaleStrokes) { this.image = image; this.scaleStrokes = scaleStrokes; ExportRectangle bounds = new ExportRectangle(shape.getBounds()); @@ -177,6 +177,7 @@ public class BitmapExporter extends ShapeExporterBase { at.preConcatenate(AffineTransform.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); graphics.setTransform(at); defaultStroke = graphics.getStroke(); + this.unzoom = unzoom; super.export(); } @@ -187,10 +188,11 @@ public class BitmapExporter extends ShapeExporterBase { thicknessScaleX = Math.abs(p11.x - p00.x); thicknessScaleY = Math.abs(p11.y - p00.y); - Matrix transPre = transformation.preConcatenate(Matrix.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); + /*Matrix transPre = transformation.preConcatenate(Matrix.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); p00 = transPre.transform(0, 0); p11 = transPre.transform(1, 1); - realZoom = p00.distanceTo(p11); + realZoom = p00.distanceTo(p11) / Math.sqrt(2); + System.out.println("realZoom=" + realZoom);*/ } public SerializableImage getImage() { @@ -427,10 +429,9 @@ public class BitmapExporter extends ShapeExporterBase { } } - //always display minimum strokem of 1 pixel, no matter how zoomed it is - if (thickness * realZoom < 1) { - //thickness = 1 / realZoom; - //TODO: fix for #1684 + //always display minimum stroke of 1 pixel, no matter how zoomed it is + if (thickness * unzoom < 1 * SWF.unitDivisor) { + thickness = 1 * SWF.unitDivisor / unzoom; } if (joinStyle == BasicStroke.JOIN_MITER) { 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 589d3b293..93324d671 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 @@ -1149,7 +1149,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(st.getShapeNum(), swf, st.shapes, Color.yellow, si, new Matrix(), new Matrix(), null, true); + BitmapExporter.export(st.getShapeNum(), swf, st.shapes, Color.yellow, si, 1, new Matrix(), new Matrix(), null, true); List li = new ArrayList<>(); li.add(st); ImageIO.write(si.getBufferedImage(), "PNG", new File(name + ".imported.png")); 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 9bebfd794..7df362f9a 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 @@ -234,7 +234,7 @@ public abstract class ImageTag extends DrawableTag { @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(1, swf, getShape(), null, image, transformation, strokeTransformation, colorTransform, true); + BitmapExporter.export(1, swf, getShape(), null, image, unzoom, transformation, strokeTransformation, colorTransform, true); } @Override 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 d44aed8f0..8ea363080 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(getShapeNum() == 2 ? 4 : 1, swf, shape, null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); + BitmapExporter.export(getShapeNum() == 2 ? 4 : 1, swf, shape, null, image, unzoom, transformation, strokeTransformation, colorTransform, scaleStrokes); } @Override 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 e721315ab..5e8c599ec 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 @@ -191,7 +191,7 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject { @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(getShapeNum(), swf, getShapes(), null, image, transformation, strokeTransformation, colorTransform, scaleStrokes); + BitmapExporter.export(getShapeNum(), swf, getShapes(), null, image, unzoom, transformation, strokeTransformation, colorTransform, scaleStrokes); if (Configuration._debugMode.get()) { // show control points List paths = PathExporter.export(getShapeNum(), swf, getShapes()); double[] coords = new double[6]; 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 f6623f15a..0c8ddd6d4 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(1, swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, mat, colorTransform, true); + BitmapExporter.export(1, swf, getBorderShape(borderColor, fillColor, rect), null, image, 1 /*FIXME??*/, mat, mat, colorTransform, true); } public static void drawBorderHtmlCanvas(SWF swf, StringBuilder result, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double unitDivisor) { @@ -512,7 +512,7 @@ public abstract class TextTag extends DrawableTag { } if (shape != null) { - BitmapExporter.export(1, swf, shape, textColor2, image, mat, mat, colorTransform, true); + BitmapExporter.export(1, swf, shape, textColor2, image, 1 /*FIXME??*/, 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)); 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 e466cff61..ea48f645e 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 @@ -219,7 +219,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali Matrix transformation = Matrix.getTranslateInstance(px, py); transformation.scale(ratio); - BitmapExporter.export(shapeNum, swf, shape, color, image, transformation, transformation, colorTransform, true); + BitmapExporter.export(shapeNum, swf, shape, color, image, 1 /*FIXME??*/, transformation, transformation, colorTransform, true); // draw bounding boxes if (DRAW_BOUNDING_BOX) {