From 084da5d6a147eada2d4b2c73c7ed458f849f6e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 7 Mar 2016 22:17:59 +0100 Subject: [PATCH] #1193 FLA export - smoothed image detection, export raw JPEG data, no recompression --- .../decompiler/flash/xfl/XFLConverter.java | 49 +++++++++++++++++-- .../com/jpexs/helpers/SerializableImage.java | 6 +-- 2 files changed, 48 insertions(+), 7 deletions(-) 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 359a93fcf..dffe8cd8b 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 @@ -116,14 +116,18 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; @@ -1365,13 +1369,50 @@ public class XFLConverter { symbols.add(symbLinkStr); } else if (symbol instanceof ImageTag) { ImageTag imageTag = (ImageTag) symbol; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + boolean allowSmoothing = false; + + //find if smoothed - a bitmap is smoothed when there is a shape with fillstyle smoothed bitmap + looptags: + for (Tag tag : swf.getTags()) { + if (tag instanceof ShapeTag) { + Set needed = new HashSet<>(); + tag.getNeededCharacters(needed); + ShapeTag sht = (ShapeTag) tag; + if (needed.contains(imageTag.getCharacterId())) { + List fs = new ArrayList<>(); + SHAPEWITHSTYLE s = sht.getShapes(); + for (FILLSTYLE f : s.fillStyles.fillStyles) { + fs.add(f); + } + for (SHAPERECORD r : s.shapeRecords) { + if (r instanceof StyleChangeRecord) { + StyleChangeRecord scr = (StyleChangeRecord) r; + if (scr.stateNewStyles) { + for (FILLSTYLE f : scr.fillStyles.fillStyles) { + fs.add(f); + } + } + } + } + for (FILLSTYLE f : fs) { + if (Arrays.asList(FILLSTYLE.REPEATING_BITMAP, FILLSTYLE.CLIPPED_BITMAP, FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP, FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP).contains(f.fillStyleType) && f.bitmapId == imageTag.getCharacterId()) { + allowSmoothing = f.fillStyleType == FILLSTYLE.CLIPPED_BITMAP || f.fillStyleType == FILLSTYLE.REPEATING_BITMAP; + break looptags; + } + } + } + } + } + + byte imageBytes[] = Helper.readStream(imageTag.getImageData()); SerializableImage image = imageTag.getImage(false); ImageFormat format = imageTag.getImageFormat(); - ImageHelper.write(image.getBufferedImage(), format, baos); String symbolFile = "bitmap" + symbol.getCharacterId() + imageTag.getImageFormat().getExtension(); - files.put(symbolFile, baos.toByteArray()); - String mediaLinkStr = "