Issue #677 Zoom level in export settings

This commit is contained in:
Jindra Petřík
2014-09-26 16:43:23 +02:00
parent f202a81ddc
commit 472f1830d7
34 changed files with 554 additions and 410 deletions

View File

@@ -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<Integer> 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<SerializableImage> ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack<Integer> 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;

View File

@@ -333,6 +333,11 @@ public class Configuration {
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("debug")
public static final ConfigurationItem<Boolean> showMethodBodyId = null;
@ConfigurationDefaultDouble(1.0)
@ConfigurationCategory("export")
public static final ConfigurationItem<Double> lastSelectedExportZoom = null;
public static final ConfigurationItem<String> 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;
}

View File

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

View File

@@ -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<BoundedTag>()));
rect.xMax*=settings.zoom;
rect.yMax*=settings.zoom;
rect.xMin*=settings.zoom;
rect.yMin*=settings.zoom;
SVGExporter exporter = new SVGExporter(rect);
SVGExporter exporter = new SVGExporter(rect);
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0,settings.zoom);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;

View File

@@ -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 File file = new File(outdir + File.separator + characterID + "." + ext);
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<BoundedTag>()));
rect.xMax*=settings.zoom;
rect.yMax*=settings.zoom;
rect.xMin*=settings.zoom;
rect.yMin*=settings.zoom;
SVGExporter exporter = new SVGExporter(rect);
SVGExporter exporter = new SVGExporter(rect);
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;
case PNG:
RECT rect = st.getRect(new HashSet<BoundedTag>());
RECT rect = st.getRect(new HashSet<BoundedTag>());
int newWidth = (int) (rect.getWidth() / 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;
int deltaY = -shp.getBounds().Ymin;
CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor/settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY);
cse.export();
Set<Integer> needed = new HashSet<>();
needed.add(st.getCharacterId());

View File

@@ -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<BoundedTag>()));
SVGExporter exporter = new SVGExporter(rect);
SVGExporter exporter = new SVGExporter(rect);
textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
}

View File

@@ -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, 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"
pathData += "M"
+ roundPixels20(x / SWF.unitDivisor) + " "
+ roundPixels20(x * zoom/ SWF.unitDivisor) + " "
+ roundPixels20(y * zoom / SWF.unitDivisor) + " ";
pathDataEnd += "M"
pathDataEnd += "M"
+ roundPixels20(x2 / 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) + " "
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) + " "
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() {

View File

@@ -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) {
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) {
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;
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();
finalizePath();
thickness /= 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/zoom, 1));
// QR decomposition
// QR decomposition
double translateX = roundPixels400(matrix.translateX / 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 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 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 translateXEnd = roundPixels400(matrixEnd.translateX * zoom / SWF.unitDivisor);
double translateYEnd = roundPixels400(matrixEnd.translateY * zoom / SWF.unitDivisor);
a = matrixEnd.scaleX;
b = matrixEnd.rotateSkew0;
c = matrixEnd.rotateSkew1;

View File

@@ -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, double zoom) {
this.mode = mode;
this.zoom = zoom;
}
}

View File

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

View File

@@ -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, double zoom) {
this.mode = mode;
this.zoom = zoom;
}
}

View File

@@ -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, double zoom) {
this.mode = mode;
this.zoom = zoom;
}
}

View File

@@ -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, double zoom) {
this.mode = mode;
this.singleFile = singleFile;
this.zoom = zoom;
}
}

View File

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

View File

@@ -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, 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"
pathData += "M"
+ roundPixels20(x / 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) + " "
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) + " "
pathData += roundPixels20(controlX * zoom / SWF.unitDivisor) + " "
+ roundPixels20(controlY * zoom / SWF.unitDivisor) + " "
+ roundPixels20(anchorX * zoom / SWF.unitDivisor) + " "
+ roundPixels20(anchorY * zoom / SWF.unitDivisor) + " ";
}
protected void finalizePath() {

View File

@@ -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) {
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) {
if (matrix != null) {
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();
finalizePath();
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) {
if (matrix != null) {
gradient.setAttribute("gradientTransform", matrix.getTransformationString(SWF.unitDivisor/zoom, 1));
}
for (int i = 0; i < gradientRecords.length; i++) {
GRADRECORD record = gradientRecords[i];

View File

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

View File

@@ -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
@Override
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
if (ratio == -2) {
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, zoom);
shapeExporter.export();
} else {
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, zoom);
shapeExporter.export();
}
}

View File

@@ -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
@Override
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
if (ratio == -2) {
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, zoom);
shapeExporter.export();
} else {
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, zoom);
shapeExporter.export();
}
}

View File

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

View File

@@ -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<BoundedTag>()), getTextMatrix(), colorTransform);
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
staticTextToSVG(swf, textRecords, 2, exporter, getRect(new HashSet<BoundedTag>()), getTextMatrix(), colorTransform, zoom);
}
@Override

View File

@@ -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<BoundedTag>()), getTextMatrix(), colorTransform);
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
staticTextToSVG(swf, textRecords, 1, exporter, getRect(new HashSet<BoundedTag>()), getTextMatrix(), colorTransform, zoom);
}
@Override

View File

@@ -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
@Override
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 {
SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1, zoom);
}
public DefineButtonSoundTag getSounds() {

View File

@@ -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, double zoom) throws IOException;
public String toHtmlCanvas(double unitDivisor);

View File

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

View File

@@ -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
@Override
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 {
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), exporter, null, colorTransform, zoom);
shapeExporter.export();
}

View File

@@ -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
@Override
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 {
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), exporter, null, colorTransform, zoom);
shapeExporter.export();
}

View File

@@ -365,7 +365,7 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
return ret;
}
public static void staticTextToSVG(SWF swf, List<TEXTRECORD> textRecords, int numText, SVGExporter exporter, RECT bounds, MATRIX textMatrix, ColorTransform colorTransform) {
public static void staticTextToSVG(SWF swf, List<TEXTRECORD> 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);