Fixed #2112 GFX - new image types in DefineExternalImage

This commit is contained in:
Jindra Petřík
2023-11-05 09:52:29 +01:00
parent 06051a5727
commit 5ed91c7ba8
2 changed files with 27 additions and 6 deletions

View File

@@ -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

View File

@@ -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);
}