mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 16:10:45 +00:00
frame SVG export: text positions fixed
This commit is contained in:
@@ -2671,8 +2671,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
// TODO: if (layer.filters != null)
|
||||
// TODO: if (layer.blendMode > 1)
|
||||
String assetPath = level == 0 ? exporterContext.assetsDir + File.separator + assetFileName : assetFileName;
|
||||
Matrix mat = new Matrix(layer.matrix);
|
||||
mat.translate(rect.xMin, rect.yMin);
|
||||
Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix));
|
||||
exporter.addImage(mat, boundRect, assetPath);
|
||||
|
||||
// TODO: if (layer.clipDepth > -1)...
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
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.Point;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -245,12 +244,6 @@ public class DefineButton2Tag extends ButtonTag implements Container {
|
||||
return trackAsMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
RECT r = getRect();
|
||||
return new Point(r.Xmin / SWF.unitDivisor, r.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 1;
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
@@ -273,12 +272,6 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
RECT r = getRect();
|
||||
return new Point(r.Xmin / SWF.unitDivisor, r.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 1;
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -956,11 +955,6 @@ public class DefineEditTextTag extends TextTag {
|
||||
return font;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(bounds.Xmin / SWF.unitDivisor, bounds.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 1;
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
@@ -346,13 +345,6 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(
|
||||
(startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / SWF.unitDivisor,
|
||||
(startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 65536;
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
@@ -329,13 +328,6 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag {
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(
|
||||
(startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / SWF.unitDivisor,
|
||||
(startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 65536;
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -41,11 +40,6 @@ public class DefineShape2Tag extends ShapeTag {
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 22;
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShapeNum() {
|
||||
return 2;
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -41,11 +40,6 @@ public class DefineShape3Tag extends ShapeTag {
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 32;
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShapeNum() {
|
||||
return 3;
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -49,11 +48,6 @@ public class DefineShape4Tag extends ShapeTag {
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 83;
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShapeNum() {
|
||||
return 4;
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
@@ -103,15 +102,6 @@ public class DefineShapeTag extends ShapeTag {
|
||||
return svgExporter.getSVG();
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform);
|
||||
}*/
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 1;
|
||||
|
||||
@@ -22,7 +22,6 @@ 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.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -291,12 +290,7 @@ 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(), new ColorTransform(), null, level + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(0, 0);
|
||||
return SWF.frameToSvg(getTimeline(), 0, 0, null, 0, exporterContext, getRect(), colorTransform, null, level + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -495,12 +494,7 @@ public class DefineText2Tag extends TextTag {
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return staticTextToSVG(swf, textRecords, 2, getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(textBounds.Xmin / 20, textBounds.Ymin / 20);
|
||||
return staticTextToSVG(swf, textRecords, 2, getRect(), getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -511,12 +510,7 @@ public class DefineTextTag extends TextTag {
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return staticTextToSVG(swf, textRecords, 1, getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(textBounds.Xmin / SWF.unitDivisor, textBounds.Ymin / SWF.unitDivisor);
|
||||
return staticTextToSVG(swf, textRecords, 1, getRect(), getTextMatrix(), colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.types.BUTTONRECORD;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Shape;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -59,9 +60,8 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) {
|
||||
return "";
|
||||
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
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 DefineButtonSoundTag getSounds() {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -35,8 +34,6 @@ public interface DrawableTag extends BoundedTag {
|
||||
|
||||
public String toSVG(SVGExporterContext exporterContext, int ratio, ColorTransform colorTransform, int level) throws IOException;
|
||||
|
||||
public Point getImagePos(int frame);
|
||||
|
||||
public int getNumFrames();
|
||||
|
||||
public boolean isSingleFrame();
|
||||
|
||||
@@ -19,7 +19,6 @@ 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.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFontNameTag;
|
||||
@@ -264,11 +263,6 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
int frameCount = (getGlyphShapeTable().size() - 1) / SHAPERECORD.MAX_CHARACTERS_IN_FONT_PREVIEW + 1;
|
||||
|
||||
@@ -305,7 +305,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
}
|
||||
}
|
||||
|
||||
public static String staticTextToSVG(SWF swf, List<TEXTRECORD> textRecords, int numText, MATRIX textMatrix, ColorTransform colorTransform) {
|
||||
public static String staticTextToSVG(SWF swf, List<TEXTRECORD> textRecords, int numText, RECT bounds, MATRIX textMatrix, ColorTransform colorTransform) {
|
||||
Color textColor = new Color(0, 0, 0);
|
||||
FontTag font = null;
|
||||
int textHeight = 12;
|
||||
@@ -336,8 +336,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
double rat = textHeight / 1024.0 / font.getDivider();
|
||||
|
||||
for (GLYPHENTRY entry : rec.glyphEntries) {
|
||||
Matrix matTr = Matrix.getTranslateInstance(x, y);
|
||||
Matrix mat = new Matrix(textMatrix).concatenate(matTr).concatenate(Matrix.getScaleInstance(rat));
|
||||
Matrix mat = (new Matrix(textMatrix).concatenate(Matrix.getTranslateInstance(x - bounds.Xmin, y - bounds.Ymin))).concatenate(Matrix.getScaleInstance(rat));
|
||||
if (entry.glyphIndex != -1) {
|
||||
// shapeNum: 1
|
||||
SHAPE shape = glyphs.get(entry.glyphIndex);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags.gfx;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFont2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
@@ -108,11 +107,6 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
|
||||
shapeCache = fonts.get(0).getGlyphShapes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user