From 5ed91c7ba81b46b2c2a160eb716d57c51c33cd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 5 Nov 2023 09:52:29 +0100 Subject: [PATCH] Fixed #2112 GFX - new image types in DefineExternalImage --- CHANGELOG.md | 2 ++ .../flash/tags/gfx/DefineExternalImage.java | 31 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8e9eb519..e9ac2626f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ All notable changes to this project will be documented in this file. - [#2108] Cannot change text when ShiftJIS flag is set on font - [#2074], [#2074] Use mxmlc.bat file when exe not available for Flex SDK compilation - FLA export - DefineEditText - allow negative letterspacing +- [#2112] GFX - new image types in DefineExternalImage ### Changed - Basic tag info panel always visible even when nothing to display (to avoid flickering) @@ -3257,6 +3258,7 @@ Major version of SWF to XML export changed to 2. [#2048]: https://www.free-decompiler.com/flash/issues/2048 [#2108]: https://www.free-decompiler.com/flash/issues/2108 [#2074]: https://www.free-decompiler.com/flash/issues/2074 +[#2112]: https://www.free-decompiler.com/flash/issues/2112 [#802]: https://www.free-decompiler.com/flash/issues/802 [#2099]: https://www.free-decompiler.com/flash/issues/2099 [#2090]: https://www.free-decompiler.com/flash/issues/2090 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java index 460756b4f..cfd85d686 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java @@ -65,6 +65,14 @@ public class DefineExternalImage extends ImageTag { public static final int BITMAP_FORMAT_TGA = 1; public static final int BITMAP_FORMAT_DDS = 2; + + //It looks like gfxexport produces BITMAP_FORMAT2_* values for format, + //but BITMAP_FORMAT_* works the same way + public static final int BITMAP_FORMAT2_JPEG = 10; + + public static final int BITMAP_FORMAT2_TGA = 13; + + public static final int BITMAP_FORMAT2_DDS = 14; @HideInRawEdit private SerializableImage serImage; @@ -174,14 +182,13 @@ public class DefineExternalImage extends ImageTag { if (targetWidth <= 0 || targetHeight <= 0) { serImage = new SerializableImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR_PRE); serImage.fillTransparent(); - return; - } - - if (bitmapFormat == BITMAP_FORMAT_TGA) { + } else if (bitmapFormat == BITMAP_FORMAT2_JPEG || bitmapFormat == BITMAP_FORMAT2_TGA || bitmapFormat == BITMAP_FORMAT_TGA) { Path imagePath = getSwf().getFile() == null ? null : Paths.get(getSwf().getFile()).getParent().resolve(Paths.get(fileName)); if (imagePath != null && imagePath.toFile().exists()) { try { - TgaSupport.init(); + if (bitmapFormat == BITMAP_FORMAT2_TGA || bitmapFormat == BITMAP_FORMAT_TGA) { + TgaSupport.init(); + } BufferedImage bufImage = ImageIO.read(imagePath.toFile()); Image scaled = bufImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_DEFAULT); bufImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB); @@ -194,7 +201,7 @@ public class DefineExternalImage extends ImageTag { } else { createFailedImage(); } - } else { + } else if (bitmapFormat == BITMAP_FORMAT2_DDS || bitmapFormat == BITMAP_FORMAT2_DDS) { Path imagePath = getSwf().getFile() == null ? null : Paths.get(getSwf().getFile()).getParent().resolve(Paths.get(fileName)); if (imagePath != null && imagePath.toFile().exists()) { try { @@ -206,12 +213,15 @@ public class DefineExternalImage extends ImageTag { bufImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB); bufImage.getGraphics().drawImage(scaled, 0, 0, null); serImage = new SerializableImage(bufImage); + cachedImageFilename = fileName; } catch (IOException ex) { createFailedImage(); } } else { createFailedImage(); } + } else { + createFailedImage(); } } } @@ -238,6 +248,15 @@ public class DefineExternalImage extends ImageTag { case BITMAP_FORMAT_DDS: bitmapFormatStr = "DDS (2)"; break; + case BITMAP_FORMAT2_JPEG: + bitmapFormatStr = "JPEG (10)"; + break; + case BITMAP_FORMAT2_TGA: + bitmapFormatStr = "TGA (13)"; + break; + case BITMAP_FORMAT2_DDS: + bitmapFormatStr = "DDS (14)"; + break; } tagInfo.addInfo("general", "bitmapFormat", bitmapFormatStr); }