mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-28 14:07:10 +00:00
svg zoom fix (however zooming an SVG is useless:))
This commit is contained in:
@@ -196,12 +196,12 @@ public class FrameExporter {
|
||||
rect.yMax *= settings.zoom;
|
||||
rect.xMin *= settings.zoom;
|
||||
rect.yMin *= settings.zoom;
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
|
||||
if (fbackgroundColor != null) {
|
||||
exporter.setBackGroundColor(fbackgroundColor);
|
||||
}
|
||||
|
||||
tim.toSVG(frame, 0, null, 0, exporter, null, 0, settings.zoom);
|
||||
tim.toSVG(frame, 0, null, 0, exporter, null, 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
ret.add(f);
|
||||
|
||||
@@ -96,8 +96,8 @@ public class MorphShapeExporter {
|
||||
rect.yMax *= settings.zoom;
|
||||
rect.xMin *= settings.zoom;
|
||||
rect.yMin *= settings.zoom;
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom);
|
||||
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
|
||||
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -107,8 +107,8 @@ public class ShapeExporter {
|
||||
rect.yMax *= settings.zoom;
|
||||
rect.xMin *= settings.zoom;
|
||||
rect.yMin *= settings.zoom;
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom);
|
||||
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
|
||||
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
break;
|
||||
@@ -119,8 +119,7 @@ public class ShapeExporter {
|
||||
int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor) + 1;
|
||||
SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB);
|
||||
img.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
Matrix m = Matrix.getTranslateInstance(-rect.Xmin, -rect.Ymin);
|
||||
m.scale(settings.zoom);
|
||||
st.toImage(0, 0, 0, new RenderContext(), img, false, m, m, m, new CXFORMWITHALPHA());
|
||||
if (settings.mode == ShapeExportMode.PNG) {
|
||||
|
||||
@@ -82,8 +82,8 @@ public class TextExporter {
|
||||
new RetryTask(() -> {
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
ExportRectangle rect = new ExportRectangle(textTag.getRect());
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom);
|
||||
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
|
||||
textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
@@ -189,8 +189,8 @@ public final class Matrix implements Cloneable {
|
||||
}
|
||||
|
||||
public void translate(double x, double y) {
|
||||
translateX += x;
|
||||
translateY += y;
|
||||
translateX = scaleX * x + rotateSkew1 * y + translateX;
|
||||
translateY = rotateSkew0 * x + scaleY * y + translateY;
|
||||
}
|
||||
|
||||
public void scale(double factor) {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SVGExporter {
|
||||
|
||||
public boolean useTextTag = Configuration.textExportExportFontFace.get();
|
||||
|
||||
public SVGExporter(ExportRectangle bounds) {
|
||||
public SVGExporter(ExportRectangle bounds, double zoom) {
|
||||
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
@@ -96,7 +96,7 @@ public class SVGExporter {
|
||||
if (bounds != null) {
|
||||
svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px");
|
||||
svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px");
|
||||
createDefGroup(bounds, null);
|
||||
createDefGroup(bounds, null, zoom);
|
||||
}
|
||||
} catch (ParserConfigurationException ex) {
|
||||
Logger.getLogger(SVGExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -123,10 +123,15 @@ public class SVGExporter {
|
||||
}
|
||||
|
||||
public final void createDefGroup(ExportRectangle bounds, String id) {
|
||||
createDefGroup(bounds, id, 1);
|
||||
}
|
||||
|
||||
public final void createDefGroup(ExportRectangle bounds, String id, double zoom) {
|
||||
Element g = _svg.createElement("g");
|
||||
if (bounds != null) {
|
||||
g.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
Matrix mat = Matrix.getTranslateInstance(-bounds.xMin, -bounds.yMin);
|
||||
mat.scale(zoom);
|
||||
g.setAttribute("transform", mat.getSvgTransformationString(SWF.unitDivisor, 1));
|
||||
}
|
||||
if (id != null) {
|
||||
g.setAttribute("id", id);
|
||||
|
||||
@@ -934,8 +934,8 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
|
||||
render(TextRenderMode.SVG, null, exporter, null, new Matrix(), colorTransform, zoom);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
render(TextRenderMode.SVG, null, exporter, null, new Matrix(), colorTransform, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -371,8 +371,8 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException {
|
||||
getTimeline().toSVG(0, 0, null, 0, exporter, colorTransform, level + 1, zoom);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
getTimeline().toSVG(0, 0, null, 0, exporter, colorTransform, level + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,8 +97,8 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException {
|
||||
getTimeline().toSVG(0, 0, null, 0, exporter, colorTransform, level + 1, zoom);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
getTimeline().toSVG(0, 0, null, 0, exporter, colorTransform, level + 1);
|
||||
}
|
||||
|
||||
public DefineButtonSoundTag getSounds() {
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface DrawableTag extends BoundedTag {
|
||||
|
||||
public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, boolean isClip, Matrix transformation, Matrix prevTransformation, Matrix absoluteTransformation, ColorTransform colorTransform);
|
||||
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) throws IOException;
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException;
|
||||
|
||||
public void toHtmlCanvas(StringBuilder result, double unitDivisor);
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -290,8 +290,8 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), exporter, null, colorTransform, 1);
|
||||
shapeExporter.export();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,15 +289,15 @@ public abstract class MorphShapeTag extends CharacterTag implements DrawableTag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
if (ratio == -2) {
|
||||
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
|
||||
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
|
||||
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, zoom);
|
||||
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform, 1);
|
||||
shapeExporter.export();
|
||||
} else {
|
||||
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, zoom);
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform, 1);
|
||||
shapeExporter.export();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,8 +179,8 @@ public abstract class ShapeTag extends CharacterTag implements DrawableTag, Lazy
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), exporter, null, colorTransform, 1);
|
||||
shapeExporter.export();
|
||||
}
|
||||
|
||||
|
||||
@@ -666,8 +666,8 @@ public abstract class StaticTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) {
|
||||
staticTextToSVG(swf, textRecords, getTextNum(), exporter, getRect(), textMatrix, colorTransform, zoom);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
staticTextToSVG(swf, textRecords, getTextNum(), exporter, getRect(), textMatrix, colorTransform, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -961,7 +961,7 @@ public class Timeline {
|
||||
g.setClip(prevClip);
|
||||
}
|
||||
|
||||
public void toSVG(int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level, double zoom) throws IOException {
|
||||
public void toSVG(int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level) throws IOException {
|
||||
if (getFrameCount() <= frame) {
|
||||
return;
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ public class Timeline {
|
||||
assetName = getTagIdPrefix(drawableTag, exporter);
|
||||
exporter.exportedTags.put(drawableTag, assetName);
|
||||
exporter.createDefGroup(new ExportRectangle(boundRect), assetName);
|
||||
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1, zoom);
|
||||
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1);
|
||||
exporter.endGroup();
|
||||
}
|
||||
ExportRectangle rect = new ExportRectangle(boundRect);
|
||||
|
||||
@@ -217,9 +217,8 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
|
||||
double px = x * w2 + w2 / 2 - w / 2 - minXMin * ratio;
|
||||
double py = y * h2 - minYMin * ratio;
|
||||
|
||||
Matrix transformation = new Matrix();
|
||||
transformation.translate(px, py);
|
||||
transformation = transformation.concatenate(Matrix.getScaleInstance(ratio));
|
||||
Matrix transformation = Matrix.getTranslateInstance(px, py);
|
||||
transformation.scale(ratio);
|
||||
BitmapExporter.export(swf, shape, color, image, transformation, transformation, colorTransform);
|
||||
|
||||
// draw bounding boxes
|
||||
|
||||
Reference in New Issue
Block a user