diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 457a8daa6..a69168de3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1329,6 +1329,7 @@ public final class SWF implements TreeItem, Timelined { BufferedImage img0 = images.next(); out.addVideoTrack(VideoFormatKeys.ENCODING_AVI_PNG, 1, frameRate, img0.getWidth(), img0.getHeight(), 0, 0); try { + out.write(0,img0,1); while (images.hasNext()) { out.write(0, images.next(), 1); } @@ -1468,11 +1469,16 @@ public final class SWF implements TreeItem, Timelined { int frame = fframes.get(fi); File f = new File(foutdir + File.separator + frame + ".svg"); try (FileOutputStream fos = new FileOutputStream(f)) { - SVGExporter exporter = new SVGExporter(new ExportRectangle(ftim.displayRect)); + ExportRectangle rect = new ExportRectangle(ftim.displayRect); + rect.xMax*=settings.zoom; + rect.yMax*=settings.zoom; + rect.xMin*=settings.zoom; + rect.yMin*=settings.zoom; + SVGExporter exporter = new SVGExporter(rect); if (fbackgroundColor != null) { exporter.setBackGroundColor(fbackgroundColor); } - frameToSvg(ftim, frame, 0, null, 0, exporter, new ColorTransform(), 0); + frameToSvg(ftim, frame, 0, null, 0, exporter, new ColorTransform(), 0, settings.zoom); fos.write(Utf8Helper.getBytes(exporter.getSVG())); } ret.add(f); @@ -1495,8 +1501,8 @@ public final class SWF implements TreeItem, Timelined { File f = new File(foutdir + File.separator + "frames.js"); File fmin = new File(foutdir + File.separator + "frames.min.js"); - int width = (int) (ftim.displayRect.getWidth() / SWF.unitDivisor); - int height = (int) (ftim.displayRect.getHeight() / SWF.unitDivisor); + int width = (int) (ftim.displayRect.getWidth() * settings.zoom / SWF.unitDivisor); + int height = (int) (ftim.displayRect.getHeight() * settings.zoom / SWF.unitDivisor); try (FileOutputStream fos = new FileOutputStream(f)) { fos.write(Utf8Helper.getBytes("\r\n")); Set library = new HashSet<>(); @@ -1508,8 +1514,8 @@ public final class SWF implements TreeItem, Timelined { fos.write(Utf8Helper.getBytes("function " + currentName + "(ctx,ctrans,frame,ratio,time){\r\n")); fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin / unitDivisor) + "," + (-ftim.displayRect.Ymin / unitDivisor) + ");\r\n")); - fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(unitDivisor, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); + fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin*settings.zoom / unitDivisor) + "," + (-ftim.displayRect.Ymin*settings.zoom / unitDivisor) + ");\r\n")); + fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(unitDivisor/settings.zoom, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); fos.write(Utf8Helper.getBytes("}\r\n\r\n")); @@ -1606,7 +1612,7 @@ public final class SWF implements TreeItem, Timelined { if (!hasNext()) { return null; } - return frameToImageGet(ftim, fframes.get(pos++), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false).getBufferedImage(); + return frameToImageGet(ftim, fframes.get(pos++), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false,settings.zoom).getBufferedImage(); } }; @@ -2489,7 +2495,7 @@ public final class SWF implements TreeItem, Timelined { return sb.toString(); } - public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level) throws IOException { + public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level, double zoom) throws IOException { if (timeline.frames.size() <= frame) { return; } @@ -2539,7 +2545,7 @@ public final class SWF implements TreeItem, Timelined { assetName = getTagIdPrefix(drawableTag, exporter); exporter.exportedTags.put(drawableTag, assetName); exporter.createDefGroup(new ExportRectangle(boundRect), assetName); - drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1); + drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1, zoom); exporter.endGroup(); } ExportRectangle rect = new ExportRectangle(boundRect); @@ -2583,8 +2589,8 @@ public final class SWF implements TreeItem, Timelined { return exporter.getUniqueId("tag"); } - public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache) { - String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode(); + public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache, double zoom) { + String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode()+"_"+zoom; SerializableImage image; if (useCache) { image = getFromCache(key); @@ -2598,8 +2604,8 @@ public final class SWF implements TreeItem, Timelined { } RECT rect = displayRect; - image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, - (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + image = new SerializableImage((int) (rect.getWidth()*zoom / SWF.unitDivisor) + 1, + (int) (rect.getHeight()*zoom / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); if (backGroundColor == null) { image.fillTransparent(); } else { @@ -2610,12 +2616,13 @@ public final class SWF implements TreeItem, Timelined { } Matrix m = transformation.clone(); m.translate(-rect.Xmin, -rect.Ymin); + m.scale(zoom); frameToImage(timeline, frame, time, stateUnderCursor, mouseButton, image, m, colorTransform); putToCache(key, image); return image; } - public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { + public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform, double zoom) { RECT rect = displayRect; for (int f = 0; f < timeline.frames.size(); f++) { SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, @@ -2629,7 +2636,7 @@ public final class SWF implements TreeItem, Timelined { } public static void frameToImage(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { - float unzoom = (float) SWF.unitDivisor; + double unzoom = SWF.unitDivisor; if (timeline.frames.size() <= frame) { return; } @@ -2709,21 +2716,21 @@ public final class SWF implements TreeItem, Timelined { deltaXMax = Math.max(x, deltaXMax); deltaYMax = Math.max(y, deltaYMax); } - rect.xMin -= deltaXMax * SWF.unitDivisor; - rect.xMax += deltaXMax * SWF.unitDivisor; - rect.yMin -= deltaYMax * SWF.unitDivisor; - rect.yMax += deltaYMax * SWF.unitDivisor; + rect.xMin -= deltaXMax * unzoom; + rect.xMax += deltaXMax * unzoom; + rect.yMin -= deltaYMax * unzoom; + rect.yMax += deltaYMax * unzoom; } - rect.xMin -= SWF.unitDivisor; - rect.yMin -= SWF.unitDivisor; + rect.xMin -= 1*unzoom; + rect.yMin -= 1*unzoom; rect.xMin = Math.max(0, rect.xMin); rect.yMin = Math.max(0, rect.yMin); - int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); - int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); - int deltaX = (int) (rect.xMin / SWF.unitDivisor); - int deltaY = (int) (rect.yMin / SWF.unitDivisor); + int newWidth = (int) (rect.getWidth() / unzoom); + int newHeight = (int) (rect.getHeight() / unzoom); + int deltaX = (int) (rect.xMin / unzoom); + int deltaY = (int) (rect.yMin / unzoom); newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 1; newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 3a988da46..d0e1abd62 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -333,6 +333,11 @@ public class Configuration { @ConfigurationDefaultBoolean(false) @ConfigurationCategory("debug") public static final ConfigurationItem showMethodBodyId = null; + + @ConfigurationDefaultDouble(1.0) + @ConfigurationCategory("export") + public static final ConfigurationItem lastSelectedExportZoom = null; + public static final ConfigurationItem pluginPath = null; @@ -654,6 +659,10 @@ public class Configuration { if (aString != null) { defaultValue = aString.value(); } + ConfigurationDefaultDouble aDouble = field.getAnnotation(ConfigurationDefaultDouble.class); + if (aDouble != null) { + defaultValue = aDouble.value(); + } return defaultValue; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/ConfigurationDefaultDouble.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/ConfigurationDefaultDouble.java new file mode 100644 index 000000000..3d868ca89 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/ConfigurationDefaultDouble.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2010-2014 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. */ +package com.jpexs.decompiler.flash.configuration; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author JPEXS + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ConfigurationDefaultDouble{ + + double value(); + +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java index 8331ee0aa..763e2131a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -80,8 +81,12 @@ public class MorphShapeExporter { case SVG: try (FileOutputStream fos = new FileOutputStream(file)) { ExportRectangle rect = new ExportRectangle(mst.getRect(new HashSet())); + rect.xMax*=settings.zoom; + rect.yMax*=settings.zoom; + rect.xMin*=settings.zoom; + rect.yMin*=settings.zoom; SVGExporter exporter = new SVGExporter(rect); - mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); + mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0,settings.zoom); fos.write(Utf8Helper.getBytes(exporter.getSVG())); } break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java index 11c75acca..39066bb21 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -80,7 +81,6 @@ public class ShapeExporter { } final File file = new File(outdir + File.separator + characterID + "." + ext); - final int fcharacterID = characterID; new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { @@ -89,19 +89,24 @@ public class ShapeExporter { case SVG: try (FileOutputStream fos = new FileOutputStream(file)) { ExportRectangle rect = new ExportRectangle(st.getRect(new HashSet())); + rect.xMax*=settings.zoom; + rect.yMax*=settings.zoom; + rect.xMin*=settings.zoom; + rect.yMin*=settings.zoom; SVGExporter exporter = new SVGExporter(rect); - st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); + st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); fos.write(Utf8Helper.getBytes(exporter.getSVG())); } break; case PNG: RECT rect = st.getRect(new HashSet()); - int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); - int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); + int newWidth = (int) (rect.getWidth() * settings.zoom / SWF.unitDivisor); + int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor); SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); img.fillTransparent(); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); + m.scale(settings.zoom); st.toImage(0, 0, 0, null, 0, img, m, new CXFORMWITHALPHA()); ImageIO.write(img.getBufferedImage(), "PNG", new FileOutputStream(file)); break; @@ -110,7 +115,7 @@ public class ShapeExporter { SHAPE shp = st.getShapes(); int deltaX = -shp.getBounds().Xmin; int deltaY = -shp.getBounds().Ymin; - CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); + CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor/settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); cse.export(); Set needed = new HashSet<>(); needed.add(st.getCharacterId()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java index 867b67b70..3202ae541 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -71,7 +72,7 @@ public class TextExporter { try (FileOutputStream fos = new FileOutputStream(file)) { ExportRectangle rect = new ExportRectangle(textTag.getRect(new HashSet())); SVGExporter exporter = new SVGExporter(rect); - textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0); + textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); fos.write(Utf8Helper.getBytes(exporter.getSVG())); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java index 178115b04..a74ab9e97 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; @@ -34,9 +35,11 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas protected String currentDrawCommand = ""; protected String pathData; protected String pathDataEnd; + protected double zoom; - public DefaultSVGMorphShapeExporter(SHAPE shape, SHAPE endShape, ColorTransform colorTransform) { + public DefaultSVGMorphShapeExporter(SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double zoom) { super(shape, endShape, colorTransform); + this.zoom = zoom; } @Override @@ -97,11 +100,11 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas public void moveTo(double x, double y, double x2, double y2) { currentDrawCommand = ""; pathData += "M" - + roundPixels20(x / SWF.unitDivisor) + " " - + roundPixels20(y / SWF.unitDivisor) + " "; + + roundPixels20(x * zoom/ SWF.unitDivisor) + " " + + roundPixels20(y * zoom / SWF.unitDivisor) + " "; pathDataEnd += "M" - + roundPixels20(x2 / SWF.unitDivisor) + " " - + roundPixels20(y2 / SWF.unitDivisor) + " "; + + roundPixels20(x2 * zoom / SWF.unitDivisor) + " " + + roundPixels20(y2 * zoom / SWF.unitDivisor) + " "; } @Override @@ -111,10 +114,10 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas pathData += "L"; pathDataEnd += "L"; } - pathData += roundPixels20(x / SWF.unitDivisor) + " " - + roundPixels20(y / SWF.unitDivisor) + " "; - pathDataEnd += roundPixels20(x2 / SWF.unitDivisor) + " " - + roundPixels20(y2 / SWF.unitDivisor) + " "; + pathData += roundPixels20(x * zoom / SWF.unitDivisor) + " " + + roundPixels20(y * zoom / SWF.unitDivisor) + " "; + pathDataEnd += roundPixels20(x2 * zoom / SWF.unitDivisor) + " " + + roundPixels20(y2 * zoom / SWF.unitDivisor) + " "; } @Override @@ -124,14 +127,14 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas pathData += "Q"; pathDataEnd += "Q"; } - pathData += roundPixels20(controlX / SWF.unitDivisor) + " " - + roundPixels20(controlY / SWF.unitDivisor) + " " - + roundPixels20(anchorX / SWF.unitDivisor) + " " - + roundPixels20(anchorY / SWF.unitDivisor) + " "; - pathDataEnd += roundPixels20(controlX2 / SWF.unitDivisor) + " " - + roundPixels20(controlY2 / SWF.unitDivisor) + " " - + roundPixels20(anchorX2 / SWF.unitDivisor) + " " - + roundPixels20(anchorY2 / SWF.unitDivisor) + " "; + pathData += roundPixels20(controlX * zoom / SWF.unitDivisor) + " " + + roundPixels20(controlY * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorX * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorY * zoom / SWF.unitDivisor) + " "; + pathDataEnd += roundPixels20(controlX2 * zoom / SWF.unitDivisor) + " " + + roundPixels20(controlY2 * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorX2 * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorY2 * zoom / SWF.unitDivisor) + " "; } protected void finalizePath() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java index fe8206f9d..ac6f7c323 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; @@ -51,8 +52,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { private final SWF swf; private final SVGExporter exporter; - public SVGMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform) { - super(shape, endShape, colorTransform); + public SVGMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { + super(shape, endShape, colorTransform, zoom); this.swf = swf; this.defaultColor = defaultColor; this.exporter = exporter; @@ -145,14 +146,14 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { pattern.setAttribute("height", "" + height); pattern.setAttribute("viewBox", "0 0 " + width + " " + height); if (matrix != null) { - matrix.rotateSkew0 /= SWF.unitDivisor; - matrix.rotateSkew1 /= SWF.unitDivisor; - matrix.scaleX /= SWF.unitDivisor; - matrix.scaleY /= SWF.unitDivisor; - matrixEnd.rotateSkew0 /= SWF.unitDivisor; - matrixEnd.rotateSkew1 /= SWF.unitDivisor; - matrixEnd.scaleX /= SWF.unitDivisor; - matrixEnd.scaleY /= SWF.unitDivisor; + matrix.rotateSkew0 *= zoom/SWF.unitDivisor; + matrix.rotateSkew1 *= zoom/SWF.unitDivisor; + matrix.scaleX *= zoom/SWF.unitDivisor; + matrix.scaleY *= zoom/SWF.unitDivisor; + matrixEnd.rotateSkew0 *= zoom/SWF.unitDivisor; + matrixEnd.rotateSkew1 *= zoom/SWF.unitDivisor; + matrixEnd.scaleX *= zoom/SWF.unitDivisor; + matrixEnd.scaleY *= zoom/SWF.unitDivisor; addMatrixAnimation(pattern, "patternTransform", matrix, matrixEnd); } Element imageElement = exporter.createElement("image"); @@ -168,8 +169,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { @Override public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, int miterLimit) { finalizePath(); - thickness /= SWF.unitDivisor; - thicknessEnd /= SWF.unitDivisor; + thickness *= zoom/SWF.unitDivisor; + thicknessEnd *= zoom/SWF.unitDivisor; path.setAttribute("fill", "none"); path.setAttribute("stroke", color.toHexRGB()); path.appendChild(createAnimateElement("stroke", color.toHexRGB(), colorEnd.toHexRGB())); @@ -254,11 +255,11 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { final int animationLength = 2; // todo final String animationLengthStr = animationLength + "s"; - element.setAttribute(attribute, matrix.getTransformationString(SWF.unitDivisor, 1)); + element.setAttribute(attribute, matrix.getTransformationString(SWF.unitDivisor/zoom, 1)); // QR decomposition - double translateX = roundPixels400(matrix.translateX / SWF.unitDivisor); - double translateY = roundPixels400(matrix.translateY / SWF.unitDivisor); + double translateX = roundPixels400(matrix.translateX * zoom / SWF.unitDivisor); + double translateY = roundPixels400(matrix.translateY * zoom / SWF.unitDivisor); double a = matrix.scaleX; double b = matrix.rotateSkew0; double c = matrix.rotateSkew1; @@ -270,8 +271,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { double scaleY = roundPixels400(det / r); double skewX = roundPixels400(Math.atan((a * c + b * d) / (r * r)) * 180 / Math.PI); - double translateXEnd = roundPixels400(matrixEnd.translateX / SWF.unitDivisor); - double translateYEnd = roundPixels400(matrixEnd.translateY / SWF.unitDivisor); + double translateXEnd = roundPixels400(matrixEnd.translateX * zoom / SWF.unitDivisor); + double translateYEnd = roundPixels400(matrixEnd.translateY * zoom / SWF.unitDivisor); a = matrixEnd.scaleX; b = matrixEnd.rotateSkew0; c = matrixEnd.rotateSkew1; @@ -337,8 +338,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { /* // LDU decomposition - double translateX = roundPixels400(matrix.translateX / SWF.unitDivisor); - double translateY = roundPixels400(matrix.translateY / SWF.unitDivisor); + double translateX = roundPixels400(matrix.translateX * zoom / SWF.unitDivisor); + double translateY = roundPixels400(matrix.translateY * zoom / SWF.unitDivisor); double a = matrix.scaleX; double b = matrix.rotateSkew0; double c = matrix.rotateSkew1; @@ -349,8 +350,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { double scaleY = roundPixels400(det / a); double skewX = roundPixels400(Math.atan2(c, a) * 180 / Math.PI); - double translateXEnd = roundPixels400(matrixEnd.translateX / SWF.unitDivisor); - double translateYEnd = roundPixels400(matrixEnd.translateY / SWF.unitDivisor); + double translateXEnd = roundPixels400(matrixEnd.translateX * zoom / SWF.unitDivisor); + double translateYEnd = roundPixels400(matrixEnd.translateY * zoom / SWF.unitDivisor); a = matrixEnd.scaleX; b = matrixEnd.rotateSkew0; c = matrixEnd.rotateSkew1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java index 28403544d..0cada70de 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/FramesExportSettings.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.settings; import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; @@ -24,8 +25,10 @@ import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; public class FramesExportSettings { public FramesExportMode mode; + public double zoom; - public FramesExportSettings(FramesExportMode mode) { + public FramesExportSettings(FramesExportMode mode, double zoom) { this.mode = mode; + this.zoom = zoom; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java index 91b6d5799..0122c19ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ImageExportSettings.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.settings; import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java index d49c7e3a8..43a64e41c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/MorphShapeExportSettings.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.settings; import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode; @@ -24,8 +25,10 @@ import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode; public class MorphShapeExportSettings { public MorphShapeExportMode mode; + public double zoom; - public MorphShapeExportSettings(MorphShapeExportMode mode) { + public MorphShapeExportSettings(MorphShapeExportMode mode, double zoom) { this.mode = mode; + this.zoom = zoom; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java index b0eccfaa6..e7d1cd029 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ShapeExportSettings.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.settings; import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; @@ -24,8 +25,10 @@ import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; public class ShapeExportSettings { public ShapeExportMode mode; + public double zoom; - public ShapeExportSettings(ShapeExportMode mode) { + public ShapeExportSettings(ShapeExportMode mode, double zoom) { this.mode = mode; + this.zoom = zoom; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java index 6e1894bec..a648bfde7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/TextExportSettings.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.settings; import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; @@ -25,9 +26,11 @@ public class TextExportSettings { public TextExportMode mode; public boolean singleFile; + public double zoom; - public TextExportSettings(TextExportMode mode, boolean singleFile) { + public TextExportSettings(TextExportMode mode, boolean singleFile, double zoom) { this.mode = mode; this.singleFile = singleFile; + this.zoom = zoom; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java index 4131705bc..6d1942ef3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/CanvasShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java index b5e007ca4..9dcb09285 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; @@ -33,9 +34,11 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase { protected String currentDrawCommand = ""; protected String pathData; + protected double zoom; - public DefaultSVGShapeExporter(SHAPE shape, ColorTransform colorTransform) { + public DefaultSVGShapeExporter(SHAPE shape, ColorTransform colorTransform, double zoom) { super(shape, colorTransform); + this.zoom = zoom; } @Override @@ -96,8 +99,8 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase { public void moveTo(double x, double y) { currentDrawCommand = ""; pathData += "M" - + roundPixels20(x / SWF.unitDivisor) + " " - + roundPixels20(y / SWF.unitDivisor) + " "; + + roundPixels20(x * zoom / SWF.unitDivisor) + " " + + roundPixels20(y * zoom / SWF.unitDivisor) + " "; } @Override @@ -106,8 +109,8 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase { currentDrawCommand = DRAW_COMMAND_L; pathData += "L"; } - pathData += roundPixels20(x / SWF.unitDivisor) + " " - + roundPixels20(y / SWF.unitDivisor) + " "; + pathData += roundPixels20(x * zoom / SWF.unitDivisor) + " " + + roundPixels20(y * zoom / SWF.unitDivisor) + " "; } @Override @@ -116,10 +119,10 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase { currentDrawCommand = DRAW_COMMAND_Q; pathData += "Q"; } - pathData += roundPixels20(controlX / SWF.unitDivisor) + " " - + roundPixels20(controlY / SWF.unitDivisor) + " " - + roundPixels20(anchorX / SWF.unitDivisor) + " " - + roundPixels20(anchorY / SWF.unitDivisor) + " "; + pathData += roundPixels20(controlX * zoom / SWF.unitDivisor) + " " + + roundPixels20(controlY * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorX * zoom / SWF.unitDivisor) + " " + + roundPixels20(anchorY * zoom / SWF.unitDivisor) + " "; } protected void finalizePath() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java index 7c5b2aaee..68f782516 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; @@ -51,8 +52,8 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { private final SWF swf; private final SVGExporter exporter; - public SVGShapeExporter(SWF swf, SHAPE shape, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform) { - super(shape, colorTransform); + public SVGShapeExporter(SWF swf, SHAPE shape, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) { + super(shape, colorTransform, zoom); this.swf = swf; this.defaultColor = defaultColor; this.exporter = exporter; @@ -143,7 +144,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { pattern.setAttribute("height", "" + height); pattern.setAttribute("viewBox", "0 0 " + width + " " + height); if (matrix != null) { - pattern.setAttribute("patternTransform", matrix.getTransformationString(SWF.unitDivisor, SWF.unitDivisor)); + pattern.setAttribute("patternTransform", matrix.getTransformationString(SWF.unitDivisor/zoom, SWF.unitDivisor/zoom)); } Element imageElement = exporter.createElement("image"); imageElement.setAttribute("width", "" + width); @@ -158,7 +159,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { @Override public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, int miterLimit) { finalizePath(); - thickness /= SWF.unitDivisor; + thickness *= zoom/SWF.unitDivisor; path.setAttribute("fill", "none"); path.setAttribute("stroke", color.toHexRGB()); path.setAttribute("stroke-width", Double.toString(thickness == 0 ? 1 : thickness)); @@ -253,7 +254,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { gradient.setAttribute("color-interpolation", "linearRGB"); } if (matrix != null) { - gradient.setAttribute("gradientTransform", matrix.getTransformationString(SWF.unitDivisor, 1)); + gradient.setAttribute("gradientTransform", matrix.getTransformationString(SWF.unitDivisor/zoom, 1)); } for (int i = 0; i < gradientRecords.length; i++) { GRADRECORD record = gradientRecords[i]; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 6387b598e..6e6c9ad88 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -963,7 +963,7 @@ public class DefineEditTextTag extends TextTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index e220d75b6..d8bc2b06c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWFInputStream; @@ -335,15 +336,15 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { if (ratio == -2) { SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0); SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535); - SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform); + SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, zoom); shapeExporter.export(); } else { SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform); + SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, zoom); shapeExporter.export(); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index f1d16c53f..96bd9d466 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWFInputStream; @@ -318,15 +319,15 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { if (ratio == -2) { SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0); SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535); - SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform); + SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, zoom); shapeExporter.export(); } else { SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform); + SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, zoom); shapeExporter.export(); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 4d3e0e8b1..22b2b8c6e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -300,8 +300,8 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException { + SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1, zoom); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index eacbdc38c..d2eb2b564 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -516,8 +516,8 @@ public class DefineText2Tag extends TextTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { - staticTextToSVG(swf, textRecords, 2, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { + staticTextToSVG(swf, textRecords, 2, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform, zoom); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 52cd4f70a..23d8597cd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -532,8 +532,8 @@ public class DefineTextTag extends TextTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { - staticTextToSVG(swf, textRecords, 1, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { + staticTextToSVG(swf, textRecords, 1, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform, zoom); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java index 0d8adc676..3a774a2b6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; @@ -61,8 +62,8 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException { + SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1, zoom); } public DefineButtonSoundTag getSounds() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java index de7a95c8e..273deed2a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; @@ -31,7 +32,7 @@ public interface DrawableTag extends BoundedTag { public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform); - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException; + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException; public String toHtmlCanvas(double unitDivisor); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 2a9863c5c..c8ede7cf6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -266,7 +266,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) { + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java index 96af60488..89b08b3d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; @@ -160,8 +161,8 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), exporter, null, colorTransform); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException { + SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), exporter, null, colorTransform, zoom); shapeExporter.export(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java index 7161d8411..ddfb9d3bc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; @@ -55,8 +56,8 @@ public abstract class ShapeTag extends CharacterTag implements DrawableTag { } @Override - public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException { - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), exporter, null, colorTransform); + public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException { + SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), exporter, null, colorTransform, zoom); shapeExporter.export(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 8ff72a641..2e5c71d4c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -365,7 +365,7 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { return ret; } - public static void staticTextToSVG(SWF swf, List textRecords, int numText, SVGExporter exporter, RECT bounds, MATRIX textMatrix, ColorTransform colorTransform) { + public static void staticTextToSVG(SWF swf, List textRecords, int numText, SVGExporter exporter, RECT bounds, MATRIX textMatrix, ColorTransform colorTransform, double zoom) { Color textColor = new Color(0, 0, 0); FontTag font = null; int textHeight = 12; @@ -460,7 +460,7 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { if (charId == null) { charId = exporter.getUniqueId(Helper.getValidHtmlId("font_" + font.getFontName() + "_" + ch)); exporter.createDefGroup(null, charId); - SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, exporter, null, colorTransform); + SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, exporter, null, colorTransform, zoom); shapeExporter.export(); exporter.endGroup(); chs.put(ch, charId); diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index d0afb3422..b83c54c3a 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -380,7 +380,7 @@ public class CommandLineArgumentParser { } else if (nextParam.equals("-proxy")) { parseProxy(args); } else if (nextParam.equals("-export")) { - parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format); + parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom); } else if (nextParam.equals("-compress")) { parseCompress(args); } else if (nextParam.equals("-decompress")) { @@ -779,7 +779,7 @@ public class CommandLineArgumentParser { } - private static void parseExport(List selectionClasses, Selection selection, Selection selectionIds, Queue args, AbortRetryIgnoreHandler handler, Level traceLevel, Map formats) { + private static void parseExport(List selectionClasses, Selection selection, Selection selectionIds, Queue args, AbortRetryIgnoreHandler handler, Level traceLevel, Map formats, double zoom) { if (args.size() < 3) { badArguments(); } @@ -890,9 +890,9 @@ public class CommandLineArgumentParser { System.out.println("Exporting images..."); new ImageExporter().exportImages(handler, outDir.getAbsolutePath() + File.separator + "images", extags, new ImageExportSettings(ImageExportMode.PNG_JPEG)); System.out.println("Exporting shapes..."); - new ShapeExporter().exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes", extags, new ShapeExportSettings(ShapeExportMode.SVG)); + new ShapeExporter().exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes", extags, new ShapeExportSettings(ShapeExportMode.SVG,zoom)); System.out.println("Exporting morphshapes..."); - new MorphShapeExporter().exportMorphShapes(handler, outDir.getAbsolutePath() + File.separator + "morphshapes", extags, new MorphShapeExportSettings(MorphShapeExportMode.SVG)); + new MorphShapeExporter().exportMorphShapes(handler, outDir.getAbsolutePath() + File.separator + "morphshapes", extags, new MorphShapeExportSettings(MorphShapeExportMode.SVG,zoom)); System.out.println("Exporting scripts..."); exfile.exportActionScript(handler, outDir.getAbsolutePath() + File.separator + "scripts", allExportMode, Configuration.parallelSpeedUp.get()); System.out.println("Exporting movies..."); @@ -911,7 +911,7 @@ public class CommandLineArgumentParser { if (singleTextFile == null) { singleTextFile = Configuration.textExportSingleFile.get(); } - new TextExporter().exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts", extags, new TextExportSettings(allTextFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN, singleTextFile)); + new TextExporter().exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts", extags, new TextExportSettings(allTextFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN, singleTextFile, zoom)); } break; case "image": { @@ -921,12 +921,12 @@ public class CommandLineArgumentParser { break; case "shape": { System.out.println("Exporting shapes..."); - new ShapeExporter().exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : ""), extags, new ShapeExportSettings(enumFromStr(formats.get("shape"), ShapeExportMode.class))); + new ShapeExporter().exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : ""), extags, new ShapeExportSettings(enumFromStr(formats.get("shape"), ShapeExportMode.class),zoom)); } break; case "morphshape": { System.out.println("Exporting morphshapes..."); - new MorphShapeExporter().exportMorphShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "morphshapes" : ""), extags, new MorphShapeExportSettings(enumFromStr(formats.get("morphshape"), MorphShapeExportMode.class))); + new MorphShapeExporter().exportMorphShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "morphshapes" : ""), extags, new MorphShapeExportSettings(enumFromStr(formats.get("morphshape"), MorphShapeExportMode.class),zoom)); } break; case "script": { @@ -965,7 +965,7 @@ public class CommandLineArgumentParser { } } exfile.exportFrames(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "frames" : ""), 0, frames, - new FramesExportSettings(enumFromStr(formats.get("frame"), FramesExportMode.class))); + new FramesExportSettings(enumFromStr(formats.get("frame"), FramesExportMode.class),zoom)); } break; case "sound": { @@ -987,7 +987,7 @@ public class CommandLineArgumentParser { singleTextFile = Configuration.textExportSingleFile.get(); } new TextExporter().exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), extags, - new TextExportSettings(enumFromStr(formats.get("text"), TextExportMode.class), singleTextFile)); + new TextExportSettings(enumFromStr(formats.get("text"), TextExportMode.class), singleTextFile, zoom)); } break; case "fla": { @@ -1270,11 +1270,11 @@ public class CommandLineArgumentParser { } System.out.print("Page " + page + "/" + totalPages + "..."); RECT displayRect = new RECT(ds.getTimeline().displayRect); - displayRect.Xmax *= zoom; - displayRect.Ymax *= zoom; + //displayRect.Xmax *= zoom; + //displayRect.Ymax *= zoom; Matrix m = new Matrix(); - m.scale(zoom); - BufferedImage img = SWF.frameToImageGet(ds.getTimeline(), 0, 0, null, 0, displayRect, m, new ColorTransform(), Color.white, false).getBufferedImage(); + //m.scale(zoom); + BufferedImage img = SWF.frameToImageGet(ds.getTimeline(), 0, 0, null, 0, displayRect, m, new ColorTransform(), Color.white, false, zoom).getBufferedImage(); PageFormat pf = new PageFormat(); pf.setOrientation(PageFormat.PORTRAIT); Paper p = new Paper(); diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index 099932380..9eabadf4b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -1,252 +1,298 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui; - -import com.jpexs.decompiler.flash.abc.ScriptPack; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; -import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; -import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; -import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode; -import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; -import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; -import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; -import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; -import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; -import com.jpexs.decompiler.flash.tags.base.FontTag; -import com.jpexs.decompiler.flash.tags.base.ImageTag; -import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; -import com.jpexs.decompiler.flash.tags.base.ShapeTag; -import com.jpexs.decompiler.flash.tags.base.SoundTag; -import com.jpexs.decompiler.flash.tags.base.TextTag; -import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; -import com.jpexs.decompiler.flash.treenodes.TreeNode; -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.Arrays; -import java.util.List; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - -/** - * - * @author JPEXS - */ -public class ExportDialog extends AppDialog { - - boolean cancelled = false; - - String[] optionNames = { - "shapes", - "texts", - "images", - "movies", - "sounds", - "scripts", - "binaryData", - "frames", - "fonts", - "morphshapes" - }; - - //Display options only when these classes found - Class[][] objClasses = { - {ShapeTag.class}, - {TextTag.class}, - {ImageTag.class}, - {DefineVideoStreamTag.class}, - {SoundTag.class}, - {TreeNode.class, ScriptPack.class}, - {DefineBinaryDataTag.class}, - {FrameNodeItem.class}, - {FontTag.class}, - {MorphShapeTag.class} - }; - - //Enum classes for values - Class[] optionClasses = { - ShapeExportMode.class, - TextExportMode.class, - ImageExportMode.class, - MovieExportMode.class, - SoundExportMode.class, - ScriptExportMode.class, - BinaryDataExportMode.class, - FramesExportMode.class, - FontExportMode.class, - MorphShapeExportMode.class - }; - - private final JComboBox[] combos; - - public E getValue(Class option) { - for (int i = 0; i < optionClasses.length; i++) { - if (option == optionClasses[i]) { - E values[] = option.getEnumConstants(); - return values[combos[i].getSelectedIndex()]; - } - } - return null; - } - - private void saveConfig() { - String cfg = ""; - for (int i = 0; i < optionNames.length; i++) { - int selIndex = combos[i].getSelectedIndex(); - Class c = optionClasses[i]; - Object vals[] = c.getEnumConstants(); - String key = optionNames[i] + "." + vals[selIndex].toString().toLowerCase(); - if (i > 0) { - cfg += ","; - } - cfg += key; - } - Configuration.lastSelectedExportFormats.set(cfg); - } - - public ExportDialog(List exportables) { - setTitle(translate("dialog.title")); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - cancelled = true; - } - }); - - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - JPanel comboPanel = new JPanel(null); - combos = new JComboBox[optionNames.length]; - JLabel[] labels = new JLabel[optionNames.length]; - int labWidth = 0; - for (int i = 0; i < optionNames.length; i++) { - labels[i] = new JLabel(optionNames[i]); - if (labels[i].getPreferredSize().width > labWidth) { - labWidth = labels[i].getPreferredSize().width; - } - } - String exportFormatsStr = Configuration.lastSelectedExportFormats.get(); - if ("".equals(exportFormatsStr)) { - exportFormatsStr = null; - } - String exportFormatsArr[] = new String[0]; - if (exportFormatsStr != null) { - if (exportFormatsStr.contains(",")) { - exportFormatsArr = exportFormatsStr.split(","); - } else { - exportFormatsArr = new String[]{exportFormatsStr}; - } - - } - List exportFormats = Arrays.asList(exportFormatsArr); - int comboWidth = 200; - int top = 10; - for (int i = 0; i < optionNames.length; i++) { - Class c = optionClasses[i]; - Object vals[] = c.getEnumConstants(); - String names[] = new String[vals.length]; - int itemIndex = -1; - for (int j = 0; j < vals.length; j++) { - - String key = optionNames[i] + "." + vals[j].toString().toLowerCase(); - if (exportFormats.contains(key)) { - itemIndex = j; - } - names[j] = translate(key); - } - - combos[i] = new JComboBox<>(names); - if (itemIndex > -1) { - combos[i].setSelectedIndex(itemIndex); - } - combos[i].setBounds(10 + labWidth + 10, top, comboWidth, combos[i].getPreferredSize().height); - boolean exportableExists = false; - if (exportables == null) { - exportableExists = true; - } else { - for (Object e : exportables) { - for (int j = 0; j < objClasses[i].length; j++) { - if (objClasses[i][j].isInstance(e)) { - exportableExists = true; - } - } - } - } - if (!exportableExists) { - continue; - } - JLabel lab = new JLabel(translate(optionNames[i])); - lab.setBounds(10, top, lab.getPreferredSize().width, lab.getPreferredSize().height); - comboPanel.add(lab); - comboPanel.add(combos[i]); - top += combos[i].getHeight(); - } - Dimension dim = new Dimension(10 + labWidth + 10 + comboWidth + 10, top + 10); - comboPanel.setMinimumSize(dim); - comboPanel.setPreferredSize(dim); - cnt.add(comboPanel, BorderLayout.CENTER); - - JPanel buttonsPanel = new JPanel(new FlowLayout()); - JButton okButton = new JButton(translate("button.ok")); - okButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - saveConfig(); - setVisible(false); - } - }); - - JButton cancelButton = new JButton(translate("button.cancel")); - cancelButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cancelled = true; - setVisible(false); - } - }); - - buttonsPanel.add(okButton); - buttonsPanel.add(cancelButton); - - cnt.add(buttonsPanel, BorderLayout.SOUTH); - pack(); - //setSize(245, top + getInsets().top); - View.centerScreen(this); - View.setWindowIcon(this); - getRootPane().setDefaultButton(okButton); - setModal(true); - } - - @Override - public void setVisible(boolean b) { - if (b) { - cancelled = false; - } - super.setVisible(b); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.abc.ScriptPack; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; +import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; +import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MorphShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; +import com.jpexs.decompiler.flash.tags.base.FontTag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; +import com.jpexs.decompiler.flash.tags.base.SoundTag; +import com.jpexs.decompiler.flash.tags.base.TextTag; +import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; +import com.jpexs.decompiler.flash.treenodes.TreeNode; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * + * @author JPEXS + */ +public class ExportDialog extends AppDialog { + + boolean cancelled = false; + + String[] optionNames = { + "shapes", + "texts", + "images", + "movies", + "sounds", + "scripts", + "binaryData", + "frames", + "fonts", + "morphshapes" + }; + + //Display options only when these classes found + Class[][] objClasses = { + {ShapeTag.class}, + {TextTag.class}, + {ImageTag.class}, + {DefineVideoStreamTag.class}, + {SoundTag.class}, + {TreeNode.class, ScriptPack.class}, + {DefineBinaryDataTag.class}, + {FrameNodeItem.class}, + {FontTag.class}, + {MorphShapeTag.class} + }; + + //Enum classes for values + Class[] optionClasses = { + ShapeExportMode.class, + TextExportMode.class, + ImageExportMode.class, + MovieExportMode.class, + SoundExportMode.class, + ScriptExportMode.class, + BinaryDataExportMode.class, + FramesExportMode.class, + FontExportMode.class, + MorphShapeExportMode.class + }; + + Class[] zoomClasses = { + ShapeExportMode.class, + TextExportMode.class, + FramesExportMode.class, + MorphShapeExportMode.class + }; + + private final JComboBox[] combos; + private JTextField zoomTextField = new JTextField(); + + public E getValue(Class option) { + for (int i = 0; i < optionClasses.length; i++) { + if (option == optionClasses[i]) { + E values[] = option.getEnumConstants(); + return values[combos[i].getSelectedIndex()]; + } + } + return null; + } + + public double getZoom(){ + return Double.parseDouble(zoomTextField.getText())/100; + } + + + private void saveConfig() { + String cfg = ""; + for (int i = 0; i < optionNames.length; i++) { + int selIndex = combos[i].getSelectedIndex(); + Class c = optionClasses[i]; + Object vals[] = c.getEnumConstants(); + String key = optionNames[i] + "." + vals[selIndex].toString().toLowerCase(); + if (i > 0) { + cfg += ","; + } + cfg += key; + } + Configuration.lastSelectedExportZoom.set(Double.parseDouble(zoomTextField.getText())); + Configuration.lastSelectedExportFormats.set(cfg); + } + + public ExportDialog(List exportables) { + setTitle(translate("dialog.title")); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + cancelled = true; + } + }); + + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + JPanel comboPanel = new JPanel(null); + combos = new JComboBox[optionNames.length]; + JLabel[] labels = new JLabel[optionNames.length]; + int labWidth = 0; + for (int i = 0; i < optionNames.length; i++) { + labels[i] = new JLabel(optionNames[i]); + if (labels[i].getPreferredSize().width > labWidth) { + labWidth = labels[i].getPreferredSize().width; + } + } + String exportFormatsStr = Configuration.lastSelectedExportFormats.get(); + if ("".equals(exportFormatsStr)) { + exportFormatsStr = null; + } + String exportFormatsArr[] = new String[0]; + if (exportFormatsStr != null) { + if (exportFormatsStr.contains(",")) { + exportFormatsArr = exportFormatsStr.split(","); + } else { + exportFormatsArr = new String[]{exportFormatsStr}; + } + + } + List exportFormats = Arrays.asList(exportFormatsArr); + int comboWidth = 200; + int top = 10; + boolean zoomable = false; + for (int i = 0; i < optionNames.length; i++) { + Class c = optionClasses[i]; + Object vals[] = c.getEnumConstants(); + String names[] = new String[vals.length]; + int itemIndex = -1; + for (int j = 0; j < vals.length; j++) { + + String key = optionNames[i] + "." + vals[j].toString().toLowerCase(); + if (exportFormats.contains(key)) { + itemIndex = j; + } + names[j] = translate(key); + } + + combos[i] = new JComboBox<>(names); + if (itemIndex > -1) { + combos[i].setSelectedIndex(itemIndex); + } + combos[i].setBounds(10 + labWidth + 10, top, comboWidth, combos[i].getPreferredSize().height); + boolean exportableExists = false; + if (exportables == null) { + exportableExists = true; + } else { + for (Object e : exportables) { + for (int j = 0; j < objClasses[i].length; j++) { + if (objClasses[i][j].isInstance(e)) { + exportableExists = true; + } + } + } + } + if (!exportableExists) { + continue; + } + if(Arrays.asList(zoomClasses).contains(c)){ + zoomable = true; + } + JLabel lab = new JLabel(translate(optionNames[i])); + lab.setBounds(10, top, lab.getPreferredSize().width, lab.getPreferredSize().height); + comboPanel.add(lab); + comboPanel.add(combos[i]); + top += combos[i].getHeight(); + } + int zoomWidth = 50; + if(zoomable){ + top+=2; + JLabel zlab = new JLabel(translate("zoom")); + zlab.setBounds(10, top+4, zlab.getPreferredSize().width, zlab.getPreferredSize().height); + zoomTextField.setBounds(10 + labWidth + 10, top, zoomWidth, zoomTextField.getPreferredSize().height); + JLabel pctLabel = new JLabel(translate("zoom.percent")); + pctLabel.setBounds(10 + labWidth + 10 + zoomWidth + 5, top+4, 20, pctLabel.getPreferredSize().height); + + comboPanel.add(zlab); + comboPanel.add(zoomTextField); + comboPanel.add(pctLabel); + top+=zoomTextField.getHeight(); + } + + Dimension dim = new Dimension(10 + labWidth + 10 + comboWidth + 10, top + 10); + comboPanel.setMinimumSize(dim); + comboPanel.setPreferredSize(dim); + cnt.add(comboPanel, BorderLayout.CENTER); + + JPanel buttonsPanel = new JPanel(new FlowLayout()); + JButton okButton = new JButton(translate("button.ok")); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try{ + saveConfig(); + }catch(NumberFormatException nfe){ + JOptionPane.showMessageDialog(ExportDialog.this, translate("zoom.invalid"),AppStrings.translate("error"),JOptionPane.ERROR_MESSAGE); + zoomTextField.requestFocusInWindow(); + return; + } + setVisible(false); + } + }); + + JButton cancelButton = new JButton(translate("button.cancel")); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + cancelled = true; + setVisible(false); + } + }); + + buttonsPanel.add(okButton); + buttonsPanel.add(cancelButton); + + cnt.add(buttonsPanel, BorderLayout.SOUTH); + pack(); + View.centerScreen(this); + View.setWindowIcon(this); + getRootPane().setDefaultButton(okButton); + setModal(true); + String pct = ""+Configuration.lastSelectedExportZoom.get()*100; + if(pct.endsWith(".0")){ + pct = pct.substring(0,pct.length()-2); + } + zoomTextField.setText(pct); + } + + @Override + public void setVisible(boolean b) { + if (b) { + cancelled = false; + } + super.setVisible(b); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 4046bb42d..a93e9ce53 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -86,6 +86,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private final IconPanel iconPanel; private int time = 0; private int selectedDepth = -1; + public double zoom = 1.0; public void selectDepth(int depth) { if (depth != selectedDepth) { @@ -518,8 +519,8 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } } - private static SerializableImage getFrame(SWF swf, int frame, int time, Timelined drawable, DepthState stateUnderCursor, int mouseButton, int selectedDepth) { - String key = "drawable_" + frame + "_" + drawable.hashCode() + "_" + mouseButton + "_depth" + selectedDepth + "_" + (stateUnderCursor == null ? "out" : stateUnderCursor.hashCode()); + private static SerializableImage getFrame(SWF swf, int frame, int time, Timelined drawable, DepthState stateUnderCursor, int mouseButton, int selectedDepth, double zoom) { + String key = "drawable_" + frame + "_" + drawable.hashCode() + "_" + mouseButton + "_depth" + selectedDepth + "_" + (stateUnderCursor == null ? "out" : stateUnderCursor.hashCode())+"_"+zoom; SerializableImage img = SWF.getFromCache(key); if (img == null) { if (drawable instanceof BoundedTag) { @@ -528,13 +529,14 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis if (rect == null) { //??? Why? rect = new RECT(0, 0, 1, 1); } - int width = rect.getWidth(); - int height = rect.getHeight(); + int width = (int)(rect.getWidth()*zoom); + int height = (int)(rect.getHeight()*zoom); SerializableImage image = new SerializableImage((int) (width / SWF.unitDivisor) + 1, (int) (height / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); image.fillTransparent(); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); + m.scale(zoom); drawable.getTimeline().toImage(frame, time, frame, stateUnderCursor, mouseButton, image, m, new ColorTransform()); Graphics2D gg = (Graphics2D) image.getGraphics(); @@ -551,6 +553,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis DrawableTag dt = (DrawableTag) cht; Shape outline = dt.getOutline(0, ds.time, ds.ratio, stateUnderCursor, mouseButton, new Matrix(ds.matrix)); Rectangle bounds = outline.getBounds(); + bounds.x *= zoom; + bounds.y *= zoom; + bounds.width *= zoom; + bounds.height *= zoom; bounds.x /= 20; bounds.y /= 20; bounds.width /= 20; @@ -597,7 +603,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis mat.translateX = swf.displayRect.Xmin; mat.translateY = swf.displayRect.Ymin; updatePos(lastMouseEvent, false); - SerializableImage img = getFrame(swf, frame, time, timelined, stateUnderCursor, mouseButton, selectedDepth); + SerializableImage img = getFrame(swf, frame, time, timelined, stateUnderCursor, mouseButton, selectedDepth, zoom); List sounds = new ArrayList<>(); List soundClasses = new ArrayList<>(); timeline.getSounds(frame, time, stateUnderCursor, mouseButton, sounds, soundClasses); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 01f0e40dd..94995061f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1090,11 +1090,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec ret.addAll(new ImageExporter().exportImages(handler, selFile + File.separator + "images", images, new ImageExportSettings(export.getValue(ImageExportMode.class)))); ret.addAll(new ShapeExporter().exportShapes(handler, selFile + File.separator + "shapes", shapes, - new ShapeExportSettings(export.getValue(ShapeExportMode.class)))); + new ShapeExportSettings(export.getValue(ShapeExportMode.class),export.getZoom()))); ret.addAll(new MorphShapeExporter().exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, - new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class)))); + new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class),export.getZoom()))); ret.addAll(new TextExporter().exportTexts(handler, selFile + File.separator + "texts", texts, - new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get()))); + new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get(), export.getZoom()))); ret.addAll(new MovieExporter().exportMovies(handler, selFile + File.separator + "movies", movies, new MovieExportSettings(export.getValue(MovieExportMode.class)))); ret.addAll(new SoundExporter().exportSounds(handler, selFile + File.separator + "sounds", sounds, @@ -1106,7 +1106,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec for (Entry> entry : frames.entrySet()) { ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(), - new FramesExportSettings(export.getValue(FramesExportMode.class)))); + new FramesExportSettings(export.getValue(FramesExportMode.class),export.getZoom()))); } List abcList = swf.abcList; if (abcPanel != null) { @@ -1675,11 +1675,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec swf.exportImages(errorHandler, selFile + File.separator + "images", new ImageExportSettings(export.getValue(ImageExportMode.class))); swf.exportShapes(errorHandler, selFile + File.separator + "shapes", - new ShapeExportSettings(export.getValue(ShapeExportMode.class))); + new ShapeExportSettings(export.getValue(ShapeExportMode.class),export.getZoom())); swf.exportMorphShapes(errorHandler, selFile + File.separator + "morphshapes", - new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class))); + new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class),export.getZoom())); swf.exportTexts(errorHandler, selFile + File.separator + "texts", - new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get())); + new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get(),export.getZoom())); swf.exportMovies(errorHandler, selFile + File.separator + "movies", new MovieExportSettings(export.getValue(MovieExportMode.class))); swf.exportSounds(errorHandler, selFile + File.separator + "sounds", @@ -1689,11 +1689,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec swf.exportFonts(errorHandler, selFile + File.separator + "fonts", new FontExportSettings(export.getValue(FontExportMode.class))); swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null, - new FramesExportSettings(export.getValue(FramesExportMode.class))); + new FramesExportSettings(export.getValue(FramesExportMode.class),export.getZoom())); for (CharacterTag c : swf.characters.values()) { if (c instanceof DefineSpriteTag) { swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null, - new FramesExportSettings(export.getValue(FramesExportMode.class))); + new FramesExportSettings(export.getValue(FramesExportMode.class),export.getZoom())); } } swf.exportActionScript(errorHandler, selFile, exportMode, Configuration.parallelSpeedUp.get()); diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewImage.java b/src/com/jpexs/decompiler/flash/gui/PreviewImage.java index 0e00cf22a..b08a851e8 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewImage.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewImage.java @@ -176,7 +176,7 @@ public class PreviewImage extends JPanel { if (treeItem instanceof FrameNodeItem) { FrameNodeItem fn = (FrameNodeItem) treeItem; RECT rect = swf.displayRect; - imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame() - 1, 0, null, 0, rect, new Matrix(), new ColorTransform(), null, true); + imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame() - 1, 0, null, 0, rect, new Matrix(), new ColorTransform(), null, true,1.0); width = (imgSrc.getWidth()); height = (imgSrc.getHeight()); } else if (treeItem instanceof ImageTag) { diff --git a/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties index 94e0b6b37..546954c45 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties @@ -66,3 +66,7 @@ frames.pdf = PDF fonts = Fonts fonts.ttf = TTF fonts.woff = WOFF + +zoom = Zoom +zoom.percent = % +zoom.invalid = Invalid zoom value. \ No newline at end of file