From 660520f44bb81c0be4138b1bdad5062f2ba7ebd5 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 6 Nov 2014 23:33:42 +0100 Subject: [PATCH] DefineJPEG3 tag reading fix, Caching Shape outline, zoom to fit fixed, shape caching --- .../src/com/jpexs/decompiler/flash/SWFInputStream.java | 8 +++++--- .../src/com/jpexs/decompiler/flash/types/SHAPE.java | 7 +++++++ src/com/jpexs/decompiler/flash/gui/ImagePanel.java | 6 ++++-- src/com/jpexs/decompiler/flash/gui/MainPanel.java | 5 +++++ src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java | 3 ++- .../decompiler/flash/gui/player/FlashPlayerPanel.java | 3 ++- .../jpexs/decompiler/flash/gui/player/MediaDisplay.java | 2 +- .../jpexs/decompiler/flash/gui/player/PlayerControls.java | 4 ++-- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index d85ea7c54..6d16ca520 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -768,10 +768,12 @@ public class SWFInputStream implements AutoCloseable { endDumpLevel(); InflaterInputStream dis = new InflaterInputStream(new ByteArrayInputStream(data)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); + if (count > 0) { byte[] buf = new byte[4096]; - int c = 0; - while ((c = dis.read(buf)) > 0) { - baos.write(buf, 0, c); + int c = 0; + while ((c = dis.read(buf)) > 0) { + baos.write(buf, 0, c); + } } return baos.toByteArray(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java index c7a4e8d6d..ad9fc0015 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -41,6 +41,8 @@ public class SHAPE implements NeedsCharacters, Serializable { public int numLineBits; public List shapeRecords; + private Shape cachedOutline; + @Override public void getNeededCharacters(Set needed) { for (SHAPERECORD r : shapeRecords) { @@ -62,12 +64,17 @@ public class SHAPE implements NeedsCharacters, Serializable { } public Shape getOutline() { + if (cachedOutline != null) { + return cachedOutline; + } + List paths = PathExporter.export(this); Area area = new Area(); for (GeneralPath path : paths) { area.add(new Area(path)); } + cachedOutline = area; return area; } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 46092a925..2bfe0751b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -406,7 +406,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } @Override - public void zoomToFit() { + public double getZoomToFit() { if (timelined instanceof BoundedTag) { RECT bounds = ((BoundedTag) timelined).getRect(new HashSet()); double w1 = bounds.getWidth() / SWF.unitDivisor; @@ -424,8 +424,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } else { w = w2; } - zoom = (double) w / (double) w1; + return (double) w / (double) w1; } + + return 1; } public void setImage(byte[] data) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 87228fcb5..736ec5eae 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2631,6 +2631,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } return new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); } + + @Override + public int hashCode() { + return tag.hashCode(); + } }; } } diff --git a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index a74e13159..9a2040815 100644 --- a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -207,7 +207,8 @@ public class SoundTagPlayer implements MediaDisplay { } @Override - public void zoomToFit() { + public double getZoomToFit() { + return 1; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 3896b82de..87b8aa9c9 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -58,8 +58,9 @@ public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { } @Override - public void zoomToFit() { + public double getZoomToFit() { //TODO + return 1; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java index c56c7e547..70688ca3b 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java +++ b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java @@ -53,7 +53,7 @@ public interface MediaDisplay { public boolean zoomAvailable(); - public void zoomToFit(); + public double getZoomToFit(); public double getZoom(); } diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 7e8d4a149..d4be31059 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -316,8 +316,8 @@ public class PlayerControls extends JPanel implements ActionListener { updateZoom(); break; case ACTION_ZOOMFIT: - display.zoomToFit(); - //updateZoom(); + realZoom = display.getZoomToFit(); + updateZoom(); break; case ACTION_SNAPSHOT: putImageToClipBoard(display.printScreen());