From bfae9f6871a215531bf9a120ce9ab4e129d1df8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 23 Oct 2022 10:56:31 +0200 Subject: [PATCH] Fixed #1847 shape viewer and PDF exporter - correct drawing of pure vertical/horizontal shapes (zero width/height) --- CHANGELOG.md | 2 ++ .../flash/exporters/shape/BitmapExporter.java | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01695231..3b7b000f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - [#1834] PlaceObject4 tags appear as Unresolved inside of DefineSprite - [#1839] Sprite frames exported incorrectly and repeating - [#1838] AS3 - Properly handling of long unsigned values, hex values, default uint values etc. +- [#1847] shape viewer and PDF exporter - correct drawing of pure vertical/horizontal shapes (zero width/height) ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. @@ -2381,6 +2382,7 @@ All notable changes to this project will be documented in this file. [#1834]: https://www.free-decompiler.com/flash/issues/1834 [#1839]: https://www.free-decompiler.com/flash/issues/1839 [#1838]: https://www.free-decompiler.com/flash/issues/1838 +[#1847]: https://www.free-decompiler.com/flash/issues/1847 [#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/exporters/shape/BitmapExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index 9e7c42f7f..9ae9bbe85 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 @@ -167,7 +167,10 @@ public class BitmapExporter extends ShapeExporterBase { ExportRectangle bounds = new ExportRectangle(shape.getBounds()); ExportRectangle transformedBounds = strokeTransformation.transform(bounds); - this.strokeTransformation = Matrix.getScaleInstance(transformedBounds.getWidth() / bounds.getWidth(), transformedBounds.getHeight() / bounds.getHeight()); + this.strokeTransformation = Matrix.getScaleInstance( + Double.compare(bounds.getWidth(), 0.0d) == 0 /*horizontal line or single point */ ? 1 : transformedBounds.getWidth() / bounds.getWidth(), + Double.compare(bounds.getHeight(), 0.0d) == 0 /*vertical line or single point */ ? 1 : transformedBounds.getHeight() / bounds.getHeight() + ); graphics = (Graphics2D) image.getGraphics(); AffineTransform at = transformation.toTransform(); @@ -411,14 +414,8 @@ public class BitmapExporter extends ShapeExporterBase { } } - if (Double.isNaN(thickness) || Double.compare(thickness, 0.0d) == 0) { //for example when bounding box width/height is zero - lineStroke = null; - lineColor = null; - return; - } else { - if (thickness < 0) { - thickness = -thickness; - } + if (thickness < 0) { + thickness = -thickness; } if (joinStyle == BasicStroke.JOIN_MITER) {