mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-14 06:03:32 +00:00
svg export to single file
This commit is contained in:
@@ -64,7 +64,6 @@ import com.jpexs.decompiler.flash.exporters.TextExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
|
||||
@@ -100,10 +99,8 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.timeline.Clip;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
@@ -1391,8 +1388,12 @@ 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)) {
|
||||
SVGExporterContext exportContext = new SVGExporterContext(foutdir.toString(), "assets_" + frame);
|
||||
fos.write(Utf8Helper.getBytes(frameToSvg(ftim, frame, 0, null, 0, exportContext, ftim.displayRect, new ColorTransform(), fbackgroundColor, 0)));
|
||||
SVGExporter exporter = new SVGExporter(new ExportRectangle(ftim.displayRect));
|
||||
if (fbackgroundColor != null) {
|
||||
exporter.setBackGroundColor(fbackgroundColor);
|
||||
}
|
||||
frameToSvg(ftim, frame, 0, null, 0, exporter, new ColorTransform(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
ret.add(f);
|
||||
}
|
||||
@@ -2130,11 +2131,11 @@ public final class SWF implements TreeItem, Timelined {
|
||||
frames.add(i);
|
||||
}
|
||||
}
|
||||
sb.append("\tvar frame_cnt = " + timeline.getFrameCount() + ";\r\n");
|
||||
sb.append("\tvar frame_cnt = ").append(timeline.getFrameCount()).append(";\r\n");
|
||||
sb.append("\tframe = frame % frame_cnt;\r\n");
|
||||
sb.append("\tswitch(frame){\r\n");
|
||||
for (int frame = 0; frame < frames.size(); frame++) {
|
||||
sb.append("\t\tcase " + frame + ":\r\n");
|
||||
sb.append("\t\tcase ").append(frame).append(":\r\n");
|
||||
Frame frameObj = timeline.frames.get(frame);
|
||||
int maxDepth = timeline.getMaxDepth();
|
||||
for (int i = 1; i <= maxDepth; i++) {
|
||||
@@ -2221,7 +2222,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
sb.append(placeMatrix.translateX).append(",");
|
||||
sb.append(placeMatrix.translateY);
|
||||
sb.append(");\r\n");
|
||||
sb.append("\t\t\tcharacter" + layer.characterId + "(ctx," + f + "," + layer.ratio + ");\r\n");
|
||||
sb.append("\t\t\tcharacter").append(layer.characterId).append("(ctx,").append(f).append(",").append(layer.ratio).append(");\r\n");
|
||||
sb.append("\t\t\tctx.restore();\r\n");
|
||||
}
|
||||
}
|
||||
@@ -2232,13 +2233,9 @@ public final class SWF implements TreeItem, Timelined {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporterContext exporterContext, RECT displayRect, ColorTransform colorTransform, Color backGroundColor, int level) throws IOException {
|
||||
SVGExporter exporter = new SVGExporter(new ExportRectangle(displayRect), colorTransform);
|
||||
if (backGroundColor != null) {
|
||||
exporter.setBackGroundColor(backGroundColor);
|
||||
}
|
||||
public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level) throws IOException {
|
||||
if (timeline.frames.size() <= frame) {
|
||||
return exporter.getSVG();
|
||||
return;
|
||||
}
|
||||
Frame frameObj = timeline.frames.get(frame);
|
||||
// TODO g.setTransform(transformation.toTransform());
|
||||
@@ -2277,40 +2274,28 @@ public final class SWF implements TreeItem, Timelined {
|
||||
if (character instanceof DrawableTag) {
|
||||
DrawableTag drawable = (DrawableTag) character;
|
||||
|
||||
String assetFileName;
|
||||
String assetName;
|
||||
Tag drawableTag = (Tag) drawable;
|
||||
if (exporterContext.exportedTags.containsKey(drawableTag)) {
|
||||
assetFileName = exporterContext.exportedTags.get(drawableTag);
|
||||
if (exporter.exportedTags.containsKey(drawableTag)) {
|
||||
assetName = exporter.exportedTags.get(drawableTag);
|
||||
} else {
|
||||
String assetsDir = exporterContext.outDir + File.separator + exporterContext.assetsDir;
|
||||
File foutdir = new File(assetsDir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + assetsDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
assetFileName = exporterContext.exportedTags.size() + ".svg";
|
||||
exporterContext.exportedTags.put(drawableTag, assetFileName);
|
||||
File file = new File(assetsDir + File.separator + assetFileName);
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(Utf8Helper.getBytes(drawable.toSVG(exporterContext, layer.ratio, clrTrans, level + 1)));
|
||||
}
|
||||
assetName = "asset" + exporter.exportedTags.size();
|
||||
exporter.exportedTags.put(drawableTag, assetName);
|
||||
exporter.createDefGroup(new ExportRectangle(drawable.getRect()), assetName);
|
||||
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1);
|
||||
exporter.endGroup();
|
||||
}
|
||||
RECT boundRect = drawable.getRect();
|
||||
ExportRectangle rect = new ExportRectangle(boundRect);
|
||||
|
||||
// TODO: if (layer.filters != null)
|
||||
// TODO: if (layer.blendMode > 1)
|
||||
String assetPath = level == 0 ? exporterContext.assetsDir + File.separator + assetFileName : assetFileName;
|
||||
Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix));
|
||||
exporter.addImage(mat, boundRect, assetPath);
|
||||
exporter.addImage(mat, boundRect, assetName);
|
||||
|
||||
// TODO: if (layer.clipDepth > -1)...
|
||||
}
|
||||
}
|
||||
return exporter.getSVG();
|
||||
}
|
||||
|
||||
public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor) {
|
||||
|
||||
@@ -564,7 +564,7 @@ public class ActionScriptParser {
|
||||
}
|
||||
if (namespace == -1) {
|
||||
if (isInterface) {
|
||||
namespace = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_NAMESPACE, abc.constants.getStringId(packageName.equals("") ? classNameStr : packageName + ":" + classNameStr, true)), 0, true);
|
||||
namespace = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_NAMESPACE, abc.constants.getStringId(packageName.isEmpty() ? classNameStr : packageName + ":" + classNameStr, true)), 0, true);
|
||||
} else {
|
||||
namespace = packageInternalNs;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
|
||||
@@ -43,7 +41,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
|
||||
@@ -19,7 +19,8 @@ package com.jpexs.decompiler.flash.exporters;
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.RetryTask;
|
||||
import com.jpexs.decompiler.flash.RunnableIOEx;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -70,7 +71,10 @@ public class MorphShapeExporter {
|
||||
switch (settings.mode) {
|
||||
case SVG:
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(Utf8Helper.getBytes(mst.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0)));
|
||||
ExportRectangle rect = new ExportRectangle(mst.getRect());
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
import com.jpexs.decompiler.flash.RetryTask;
|
||||
import com.jpexs.decompiler.flash.RunnableIOEx;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter;
|
||||
@@ -83,7 +84,10 @@ public class ShapeExporter {
|
||||
switch (settings.mode) {
|
||||
case SVG:
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(Utf8Helper.getBytes(st.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0)));
|
||||
ExportRectangle rect = new ExportRectangle(st.getRect());
|
||||
SVGExporter exporter = new SVGExporter(rect);
|
||||
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
|
||||
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
|
||||
}
|
||||
break;
|
||||
case PNG:
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
package com.jpexs.decompiler.flash.exporters.commonshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.RGBA;
|
||||
import java.awt.Color;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@@ -53,11 +56,12 @@ public class SVGExporter {
|
||||
|
||||
protected Document _svg;
|
||||
protected Element _svgDefs;
|
||||
protected Element _svgG;
|
||||
protected Stack<Element> _svgGs = new Stack<>();
|
||||
public List<Element> gradients;
|
||||
protected int lastPatternId;
|
||||
public Map<Tag, String> exportedTags = new HashMap<>();
|
||||
|
||||
public SVGExporter(ExportRectangle bounds, ColorTransform colorTransform) {
|
||||
public SVGExporter(ExportRectangle bounds) {
|
||||
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
@@ -71,7 +75,9 @@ public class SVGExporter {
|
||||
_svgDefs = _svg.createElement("defs");
|
||||
svgRoot.appendChild(_svgDefs);
|
||||
if (bounds != null) {
|
||||
createNewGroup(bounds);
|
||||
svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px");
|
||||
svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px");
|
||||
createDefGroup(bounds, null);
|
||||
}
|
||||
} catch (ParserConfigurationException ex) {
|
||||
Logger.getLogger(SVGExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -79,28 +85,44 @@ public class SVGExporter {
|
||||
gradients = new ArrayList<>();
|
||||
}
|
||||
|
||||
public final void createNewGroup(ExportRectangle bounds) {
|
||||
_svgG = _svg.createElement("g");
|
||||
_svgG.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
public final void createDefGroup(ExportRectangle bounds, String id) {
|
||||
Element g = _svg.createElement("g");
|
||||
g.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
_svg.getDocumentElement().appendChild(_svgG);
|
||||
if (id != null) {
|
||||
g.setAttribute("id", id);
|
||||
}
|
||||
if (_svgGs.size() == 0) {
|
||||
_svg.getDocumentElement().appendChild(g);
|
||||
} else {
|
||||
_svgDefs.appendChild(g);
|
||||
}
|
||||
_svgGs.add(g);
|
||||
}
|
||||
|
||||
public void endGroup() {
|
||||
_svgGs.pop();
|
||||
}
|
||||
|
||||
public final void createNewGroup(Matrix transform) {
|
||||
_svgG = _svg.createElement("g");
|
||||
public final void createSubGroup(Matrix transform, String id) {
|
||||
Element g = _svg.createElement("g");
|
||||
double translateX = roundPixels400(transform.translateX / SWF.unitDivisor);
|
||||
double translateY = roundPixels400(transform.translateY / SWF.unitDivisor);
|
||||
double rotateSkew0 = roundPixels400(transform.rotateSkew0);
|
||||
double rotateSkew1 = roundPixels400(transform.rotateSkew1);
|
||||
double scaleX = roundPixels400(transform.scaleX);
|
||||
double scaleY = roundPixels400(transform.scaleY);
|
||||
_svgG.setAttribute("transform", "matrix(" + scaleX + ", " + rotateSkew0
|
||||
g.setAttribute("transform", "matrix(" + scaleX + ", " + rotateSkew0
|
||||
+ ", " + rotateSkew1 + ", " + scaleY + ", " + translateX + ", " + translateY + ")");
|
||||
_svg.getDocumentElement().appendChild(_svgG);
|
||||
if (id != null) {
|
||||
g.setAttribute("id", id);
|
||||
}
|
||||
_svgGs.peek().appendChild(g);
|
||||
_svgGs.add(g);
|
||||
}
|
||||
|
||||
public void addToGroup(Node newChild) {
|
||||
_svgG.appendChild(newChild);
|
||||
_svgGs.peek().appendChild(newChild);
|
||||
}
|
||||
|
||||
public void addToDefs(Node newChild) {
|
||||
@@ -133,7 +155,7 @@ public class SVGExporter {
|
||||
}
|
||||
|
||||
public void addImage(Matrix transform, RECT boundRect, String href) {
|
||||
Element image = _svg.createElement("image");
|
||||
Element image = _svg.createElement("use");
|
||||
if (transform != null) {
|
||||
double translateX = roundPixels400(transform.translateX / SWF.unitDivisor);
|
||||
double translateY = roundPixels400(transform.translateY / SWF.unitDivisor);
|
||||
@@ -146,8 +168,8 @@ public class SVGExporter {
|
||||
image.setAttribute("width", Double.toString(boundRect.getWidth() / (double) SWF.unitDivisor));
|
||||
image.setAttribute("height", Double.toString(boundRect.getHeight() / (double) SWF.unitDivisor));
|
||||
}
|
||||
image.setAttribute("xlink:href", href);
|
||||
_svgG.appendChild(image);
|
||||
image.setAttribute("xlink:href", "#" + href);
|
||||
_svgGs.peek().appendChild(image);
|
||||
}
|
||||
|
||||
protected static double roundPixels20(double pixels) {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters.commonshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SVGExporterContext {
|
||||
|
||||
public String outDir;
|
||||
public String assetsDir;
|
||||
public Map<Tag, String> exportedTags = new HashMap<>();
|
||||
|
||||
public SVGExporterContext(String outDir, String assetsDir) {
|
||||
this.outDir = outDir;
|
||||
this.assetsDir = assetsDir;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -948,8 +948,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return "";
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -329,20 +327,17 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGExporter svgExporter = new SVGExporter(rect, colorTransform);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
if (ratio == -2) {
|
||||
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
|
||||
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
|
||||
SVGMorphShapeExporter exporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, svgExporter, null, colorTransform);
|
||||
exporter.export();
|
||||
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform);
|
||||
shapeExporter.export();
|
||||
} else {
|
||||
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, shapes, svgExporter, null, colorTransform);
|
||||
exporter.export();
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform);
|
||||
shapeExporter.export();
|
||||
}
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,10 +19,8 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -312,20 +310,17 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGExporter svgExporter = new SVGExporter(rect, colorTransform);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
if (ratio == -2) {
|
||||
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
|
||||
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
|
||||
SVGMorphShapeExporter exporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, svgExporter, null, colorTransform);
|
||||
exporter.export();
|
||||
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, exporter, null, colorTransform);
|
||||
shapeExporter.export();
|
||||
} else {
|
||||
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, shapes, svgExporter, null, colorTransform);
|
||||
exporter.export();
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, exporter, null, colorTransform);
|
||||
shapeExporter.export();
|
||||
}
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
@@ -289,8 +289,8 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
return SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporterContext, getRect(), colorTransform, null, level + 1);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporter, colorTransform, level + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -499,8 +499,8 @@ public class DefineText2Tag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return staticTextToSVG(swf, textRecords, 2, getRect(), getTextMatrix(), colorTransform);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
staticTextToSVG(swf, textRecords, 2, exporter, getRect(), getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -515,8 +515,8 @@ public class DefineTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return staticTextToSVG(swf, textRecords, 1, getRect(), getTextMatrix(), colorTransform);
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
staticTextToSVG(swf, textRecords, 1, exporter, getRect(), getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
@@ -61,8 +61,8 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) throws IOException {
|
||||
return SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporterContext, getRect(), colorTransform, null, level + 1);
|
||||
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 DefineButtonSoundTag getSounds() {
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Shape;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,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 String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) throws IOException;
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException;
|
||||
|
||||
public String toHtmlCanvas(double unitDivisor);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.tags.base;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFontNameTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
|
||||
@@ -259,8 +259,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return "";
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -56,12 +54,9 @@ public abstract class ShapeTag extends CharacterTag implements BoundedTag, Drawa
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) throws IOException{
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGExporter svgExporter = new SVGExporter(rect, colorTransform);
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(), svgExporter, null, colorTransform);
|
||||
exporter.export();
|
||||
return svgExporter.getSVG();
|
||||
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException{
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), exporter, null, colorTransform);
|
||||
shapeExporter.export();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -321,7 +321,6 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
List<SHAPE> glyphs = new ArrayList<>();
|
||||
SVGExporter svgExporter = new SVGExporter(null, colorTransform);
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasColor) {
|
||||
if (numText == 2) {
|
||||
@@ -352,7 +351,6 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
ret += "ctx.transform(" + mat.scaleX + "," + mat.rotateSkew0 + "," + mat.rotateSkew1 + "," + mat.scaleY + "," + mat.translateX + "," + mat.translateY + ");\r\n";
|
||||
|
||||
SHAPE shape = glyphs.get(entry.glyphIndex);
|
||||
svgExporter.createNewGroup(mat);
|
||||
CanvasShapeExporter exporter = new CanvasShapeExporter(new RGBA(textColor),unitDivisor, swf, shape, colorTransform,0,0);
|
||||
exporter.export();
|
||||
ret += exporter.getShapeData();
|
||||
@@ -364,14 +362,13 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String staticTextToSVG(SWF swf, List<TEXTRECORD> textRecords, int numText, 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) {
|
||||
Color textColor = new Color(0, 0, 0);
|
||||
FontTag font = null;
|
||||
int textHeight = 12;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
List<SHAPE> glyphs = new ArrayList<>();
|
||||
SVGExporter svgExporter = new SVGExporter(null, colorTransform);
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasColor) {
|
||||
if (numText == 2) {
|
||||
@@ -399,14 +396,14 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
if (entry.glyphIndex != -1) {
|
||||
// shapeNum: 1
|
||||
SHAPE shape = glyphs.get(entry.glyphIndex);
|
||||
svgExporter.createNewGroup(mat);
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, shape, svgExporter, textColor, colorTransform);
|
||||
exporter.export();
|
||||
exporter.createSubGroup(mat, null);
|
||||
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, exporter, textColor, colorTransform);
|
||||
shapeExporter.export();
|
||||
exporter.endGroup();
|
||||
x += entry.glyphAdvance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.filters.FILTER;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
|
||||
Reference in New Issue
Block a user