diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 3de2f4607..9677666cb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -125,6 +125,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -224,6 +225,7 @@ public final class SWF implements TreeItem { public List abcList; public JPEGTablesTag jtt; public Map sourceFontsMap = new HashMap<>(); + public static final double unitDivisor = 20; /** * Gets all tags with specified id @@ -2097,20 +2099,22 @@ public final class SWF implements TreeItem { return ret; } - public static SerializableImage frameToImage(int containerId, int maxDepth, HashMap layers, Color backgroundColor, HashMap characters, int frame, List allTags, List controlTags, RECT displayRect, Stack visited) { - float unzoom = 20; - double fixX = 0; - double fixY = 0; - fixX = -displayRect.Xmin / unzoom; - fixY = -displayRect.Ymin / unzoom; - displayRect = fixRect(displayRect); - + public static SerializableImage frameToImage(int containerId, int maxDepth, HashMap layers, Color backgroundColor, HashMap characters, int frame, List allTags, List controlTags, RECT displayRect, Stack visited, Matrix transformation) { String key = "frame_" + frame + "_" + containerId; if (frameCache.contains(key)) { SerializableImage ciret = ((SerializableImage) frameCache.get(key)); return ciret; } + + float unzoom = (float) SWF.unitDivisor; + double fixX = -displayRect.Xmin / unzoom; + double fixY = -displayRect.Ymin / unzoom; + double width = displayRect.getWidth() / unzoom; + double height = displayRect.getHeight() / unzoom; + displayRect = fixRect(displayRect); + SerializableImage ret = new SerializableImage((int) (displayRect.getWidth() / unzoom), (int) (displayRect.getHeight() / unzoom), SerializableImage.TYPE_INT_ARGB); + ret.bounds = new Rectangle2D.Double(-fixX, -fixY, width, height); Graphics2D g = (Graphics2D) ret.getGraphics(); g.setPaint(backgroundColor); @@ -2132,11 +2136,19 @@ public final class SWF implements TreeItem { } CharacterTag character = characters.get(layer.characterId); Matrix mat = new Matrix(layer.matrix); + /*if (firstLevel) { + mat.scale(unzoom); + }*/ mat.translate(fixX, fixY); if (character instanceof DrawableTag) { DrawableTag drawable = (DrawableTag) character; - SerializableImage img = drawable.toImage(layer.ratio < 0 ? 0 : layer.ratio/*layer.duration*/, allTags, characters, visited); + SerializableImage img = drawable.toImage(layer.ratio < 0 ? 0 : layer.ratio/*layer.duration*/, allTags, characters, visited, transformation); + try { + ImageIO.write(img.getBufferedImage(), "png", new File("C:\\10\\4.png")); + } catch (IOException ex) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, null, ex); + } mat.translate(img.bounds.getMinX(), img.bounds.getMinY()); /*if (character instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) character; @@ -2213,10 +2225,11 @@ public final class SWF implements TreeItem { g.setPaint(new Color(255, 255, 255, 128)); g.setComposite(BlendComposite.Invert); RECT r = b.getRect(characters, visited); - g.drawString(character.toString(), (r.Xmin) / 20 + 3, (r.Ymin) / 20 + 15); - g.draw(new Rectangle(r.Xmin / 20, r.Ymin / 20, r.getWidth() / 20, r.getHeight() / 20)); - g.drawLine(r.Xmin / 20, r.Ymin / 20, r.Xmax / 20, r.Ymax / 20); - g.drawLine(r.Xmax / 20, r.Ymin / 20, r.Xmin / 20, r.Ymax / 20); + int div = (int) unzoom; + g.drawString(character.toString(), r.Xmin / div + 3, r.Ymin / div + 15); + g.draw(new Rectangle(r.Xmin / div, r.Ymin / div, r.getWidth() / div, r.getHeight() / div)); + g.drawLine(r.Xmin / div, r.Ymin / div, r.Xmax / div, r.Ymax / div); + g.drawLine(r.Xmax / div, r.Ymin / div, r.Xmin / div, r.Ymax / div); g.setComposite(AlphaComposite.Dst); } } @@ -2233,16 +2246,16 @@ public final class SWF implements TreeItem { return ret; } - public static SerializableImage frameToImage(int containerId, int frame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited) { + public static SerializableImage frameToImage(int containerId, int frame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation) { List ret = new ArrayList<>(); - framesToImage(containerId, ret, frame, frame, allTags, controlTags, displayRect, totalFrameCount, visited); + framesToImage(containerId, ret, frame, frame, allTags, controlTags, displayRect, totalFrameCount, visited, transformation); if (ret.isEmpty()) { return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB); } return ret.get(0); } - public static void framesToImage(int containerId, List ret, int startFrame, int stopFrame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited) { + public static void framesToImage(int containerId, List ret, int startFrame, int stopFrame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation) { for (int i = startFrame; i <= stopFrame; i++) { String key = "frame_" + i + "_" + containerId; if (frameCache.contains(key)) { @@ -2363,7 +2376,7 @@ public final class SWF implements TreeItem { break; } if ((f >= startFrame) && (f <= stopFrame)) { - ret.add(frameToImage(containerId, maxDepth, layers, backgroundColor, characters, f, allTags, controlTags, displayRect, visited)); + ret.add(frameToImage(containerId, maxDepth, layers, backgroundColor, characters, f, allTags, controlTags, displayRect, visited, transformation)); } f++; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java index 761652516..1a1feeac6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java @@ -77,25 +77,19 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter static int imageid = 0; + public static SerializableImage export(SWF swf, SHAPE shape) { + BitmapExporter exporter = new BitmapExporter(swf, shape, null, true); + exporter.export(); + return exporter.getImage(); + } + public static SerializableImage export(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache) { BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor, putToCache); exporter.export(); return exporter.getImage(); } - public BitmapExporter(SWF swf, SHAPE shape) { - this(swf, shape, null, true); - } - - public BitmapExporter(SWF swf, SHAPE shape, boolean putToCache) { - this(swf, shape, null, putToCache); - } - - public BitmapExporter(SWF swf, SHAPE shape, Color defaultColor) { - this(swf, shape, defaultColor, true); - } - - public BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache) { + private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache) { super(shape); this.swf = swf; this.defaultColor = defaultColor; @@ -120,11 +114,11 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter } } } - double maxLineWidth = maxLineWidthTwips / unitDivisor / 2; - deltaX = bounds.Xmin / unitDivisor - maxLineWidth; - deltaY = bounds.Ymin / unitDivisor - maxLineWidth; - double width = bounds.getWidth() / unitDivisor + 2 * (maxLineWidth + 1); - double height = bounds.getHeight() / unitDivisor + 2 * (maxLineWidth + 1); + double maxLineWidth = maxLineWidthTwips / SWF.unitDivisor / 2; + deltaX = bounds.Xmin / SWF.unitDivisor - maxLineWidth; + deltaY = bounds.Ymin / SWF.unitDivisor - maxLineWidth; + double width = bounds.getWidth() / SWF.unitDivisor + 2 * (maxLineWidth + 1); + double height = bounds.getHeight() / SWF.unitDivisor + 2 * (maxLineWidth + 1); image = new SerializableImage((int) width, (int) height, SerializableImage.TYPE_INT_ARGB); graphics = (Graphics2D) image.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java index cf2f44ca1..a38319892 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.MATRIX; import java.awt.geom.AffineTransform; @@ -32,21 +33,27 @@ public class Matrix { public double translateX; public double translateY; + public static Matrix getScaleInstance(double scale) { + Matrix mat = new Matrix(); + mat.scale(scale); + return mat; + } + public Matrix() { scaleX = 1; scaleY = 1; } public Matrix(MATRIX matrix) { - translateX = matrix.translateX / 20.0; - translateY = matrix.translateY / 20.0; + translateX = matrix.translateX / SWF.unitDivisor; + translateY = matrix.translateY / SWF.unitDivisor; if (matrix.hasScale) { - scaleX = matrix.getScaleXFloat() / 20.0; - scaleY = matrix.getScaleYFloat() / 20.0; + scaleX = matrix.getScaleXFloat() / SWF.unitDivisor; + scaleY = matrix.getScaleYFloat() / SWF.unitDivisor; } if (matrix.hasRotate) { - rotateSkew0 = matrix.getRotateSkew0Float() / 20.0; - rotateSkew1 = matrix.getRotateSkew1Float() / 20.0; + rotateSkew0 = matrix.getRotateSkew0Float() / SWF.unitDivisor; + rotateSkew1 = matrix.getRotateSkew1Float() / SWF.unitDivisor; } } @@ -67,6 +74,13 @@ public class Matrix { translateY += y; } + public void scale(double factor) { + scaleX *= factor; + scaleY *= factor; + rotateSkew0 *= factor; + rotateSkew1 *= factor; + } + public AffineTransform toTransform() { AffineTransform transform = new AffineTransform(scaleX, rotateSkew0, rotateSkew1, scaleY, diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java b/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java index b1c646430..0c2f268cf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java @@ -25,7 +25,7 @@ public class Point { public double x; public double y; - Point(double x, double y) { + public Point(double x, double y) { this.x = x; this.y = y; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java index 53f2fc6a0..9befa30a4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java @@ -317,10 +317,10 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { gradient.setAttribute("color-interpolation", "linearRGB"); } if (matrix != null) { - matrix.rotateSkew0 *= unitDivisor; - matrix.rotateSkew1 *= unitDivisor; - matrix.scaleX *= unitDivisor; - matrix.scaleY *= unitDivisor; + matrix.rotateSkew0 *= SWF.unitDivisor; + matrix.rotateSkew1 *= SWF.unitDivisor; + matrix.scaleX *= SWF.unitDivisor; + matrix.scaleY *= SWF.unitDivisor; double translateX = roundPixels400(matrix.translateX); double translateY = roundPixels400(matrix.translateY); double rotateSkew0 = roundPixels400(matrix.rotateSkew0); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java index 5751e7dc4..c1baf84de 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; import com.jpexs.decompiler.flash.types.LINESTYLE; @@ -44,8 +45,6 @@ public abstract class ShapeExporterBase implements IShapeExporter { protected final SHAPE shape; - protected static final double unitDivisor = 20; - protected List _fillStyles; protected List _lineStyles; @@ -155,20 +154,20 @@ public abstract class ShapeExporterBase implements IShapeExporter { } } if (styleChangeRecord.stateMoveTo) { - xPos = styleChangeRecord.moveDeltaX / unitDivisor; - yPos = styleChangeRecord.moveDeltaY / unitDivisor; + xPos = styleChangeRecord.moveDeltaX / SWF.unitDivisor; + yPos = styleChangeRecord.moveDeltaY / SWF.unitDivisor; } } else if (shapeRecord instanceof StraightEdgeRecord) { StraightEdgeRecord straightEdgeRecord = (StraightEdgeRecord) shapeRecord; from = new Point(roundPixels400(xPos), roundPixels400(yPos)); if (straightEdgeRecord.generalLineFlag) { - xPos += straightEdgeRecord.deltaX / unitDivisor; - yPos += straightEdgeRecord.deltaY / unitDivisor; + xPos += straightEdgeRecord.deltaX / SWF.unitDivisor; + yPos += straightEdgeRecord.deltaY / SWF.unitDivisor; } else { if (straightEdgeRecord.vertLineFlag) { - yPos += straightEdgeRecord.deltaY / unitDivisor; + yPos += straightEdgeRecord.deltaY / SWF.unitDivisor; } else { - xPos += straightEdgeRecord.deltaX / unitDivisor; + xPos += straightEdgeRecord.deltaX / SWF.unitDivisor; } } to = new Point(roundPixels400(xPos), roundPixels400(yPos)); @@ -176,10 +175,10 @@ public abstract class ShapeExporterBase implements IShapeExporter { } else if (shapeRecord instanceof CurvedEdgeRecord) { CurvedEdgeRecord curvedEdgeRecord = (CurvedEdgeRecord) shapeRecord; from = new Point(roundPixels400(xPos), roundPixels400(yPos)); - double xPosControl = xPos + curvedEdgeRecord.controlDeltaX / unitDivisor; - double yPosControl = yPos + curvedEdgeRecord.controlDeltaY / unitDivisor; - xPos = xPosControl + curvedEdgeRecord.anchorDeltaX / unitDivisor; - yPos = yPosControl + curvedEdgeRecord.anchorDeltaY / unitDivisor; + double xPosControl = xPos + curvedEdgeRecord.controlDeltaX / SWF.unitDivisor; + double yPosControl = yPos + curvedEdgeRecord.controlDeltaY / SWF.unitDivisor; + xPos = xPosControl + curvedEdgeRecord.anchorDeltaX / SWF.unitDivisor; + yPos = yPosControl + curvedEdgeRecord.anchorDeltaY / SWF.unitDivisor; control = new Point(xPosControl, yPosControl); to = new Point(roundPixels400(xPos), roundPixels400(yPos)); subPath.add(new CurvedEdge(from, control, to, currentLineStyleIdx, currentFillStyleIdx1)); @@ -297,7 +296,6 @@ public abstract class ShapeExporterBase implements IShapeExporter { case FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP: // Bitmap fill matrix = new Matrix(fillStyle.bitmapMatrix); - //matrix = new MATRIX(m.scaleX / 20.0, m.scaleY / 20.0, m.getRotation(), m.translateX / 20.0, m.translateY / 20.0); beginBitmapFill( fillStyle.bitmapId, matrix, @@ -373,7 +371,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { hasFillFlag = lineStyle2.hasFillFlag; } lineStyle( - lineStyle.width / unitDivisor, + lineStyle.width / SWF.unitDivisor, lineStyle.color, pixelHintingFlag, scaleMode, diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 626e7be2d..de4e93815 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -124,7 +124,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis Matrix mat = new Matrix(); mat.translateX = swf.displayRect.Xmin; mat.translateY = swf.displayRect.Ymin; - SerializableImage img = drawable.toImage(0, swf.tags, characters, new Stack()); + SerializableImage img = drawable.toImage(0, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); mat.translate(img.bounds.getMinX(), img.bounds.getMinY()); setImage(img); return; @@ -180,7 +180,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis Matrix mat = new Matrix(); mat.translateX = swf.displayRect.Xmin; mat.translateY = swf.displayRect.Ymin; - SerializableImage img = drawable.toImage(nframe, swf.tags, characters, new Stack()); + SerializableImage img = drawable.toImage(nframe, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); mat.translate(img.bounds.getMinX(), img.bounds.getMinY()); ImageIcon icon = new ImageIcon(img.getBufferedImage()); label.setIcon(icon); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 6d762ab62..a2dcf23d6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -270,8 +270,8 @@ public class Main { logger.log(Level.INFO, "== File information =="); logger.log(Level.INFO, "Size: {0}", Helper.formatFileSize(swf.fileSize)); logger.log(Level.INFO, "Flash version: {0}", swf.version); - int width = (swf.displayRect.Xmax - swf.displayRect.Xmin) / 20; - int height = (swf.displayRect.Ymax - swf.displayRect.Ymin) / 20; + int width = (int) ((swf.displayRect.Xmax - swf.displayRect.Xmin) / SWF.unitDivisor); + int height = (int) ((swf.displayRect.Ymax - swf.displayRect.Ymin) / SWF.unitDivisor); logger.log(Level.INFO, "Width: {0}", width); logger.log(Level.INFO, "Height: {0}", height); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 0cd1e2698..f858d7eb4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.Matrix; import com.jpexs.decompiler.flash.gui.abc.ABCPanel; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; @@ -2364,7 +2365,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec rect = ((DefineSpriteTag) fn.getParent()).getRect(swf.characters, new Stack()); totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount; } - previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack())); + previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor))); } else if (((tagObj instanceof FrameNodeItem) && ((FrameNodeItem) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) { ((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD); createAndShowTempSwf(tagObj); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java index b1d3a2061..3c2b8c395 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.AppStrings; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.exporters.Matrix; import com.jpexs.decompiler.flash.gui.player.FlashDisplay; import com.jpexs.decompiler.flash.gui.player.PlayerControls; import com.jpexs.helpers.SerializableImage; @@ -66,7 +67,7 @@ public class SWFPreviwPanel extends JPanel implements FlashDisplay { @Override public void run() { buffering.setVisible(true); - SWF.framesToImage(0, frameImages, 0, swf.frameCount - 1, swf.tags, swf.tags, swf.displayRect, swf.frameCount, new Stack()); + SWF.framesToImage(0, frameImages, 0, swf.frameCount - 1, swf.tags, swf.tags, swf.displayRect, swf.frameCount, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); buffering.setVisible(false); } }.start(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index 7d6348d8e..0dbaabc87 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -22,6 +22,8 @@ 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.Matrix; +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; @@ -34,7 +36,6 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; import java.awt.Color; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -242,7 +243,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { if (visited.contains(buttonId)) { return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR); } @@ -266,7 +267,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded visited.pop(); RECT displayRect = getRect(characters, visited); visited.push(buttonId); - SerializableImage ret = SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited); + SerializableImage ret = SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, transformation); return ret; } @@ -274,7 +275,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { RECT r = getRect(characters, visited); - return new Point(r.Xmin / 20, r.Ymin / 20); + return new Point(r.Xmin / SWF.unitDivisor, r.Ymin / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 72bd490d9..d3f7d3712 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -25,6 +25,8 @@ 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.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; @@ -39,7 +41,6 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import com.jpexs.helpers.SerializableImage; import java.awt.Color; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -265,7 +266,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { if (visited.contains(buttonId)) { return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR); } @@ -289,7 +290,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT visited.pop(); RECT displayRect = getRect(characters, visited); visited.push(buttonId); - SerializableImage ret = SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited); + SerializableImage ret = SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, transformation); visited.pop(); return ret; } @@ -297,7 +298,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { RECT r = getRect(characters, visited); - return new Point(r.Xmin / 20, r.Ymin / 20); + return new Point(r.Xmin / SWF.unitDivisor, r.Ymin / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index 68ed5dcfa..0515fd2bc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -74,7 +74,7 @@ public class DefineFont2Tag extends FontTag { } @Override - public int getGlyphAdvance(int glyphIndex) { + public double getGlyphAdvance(int glyphIndex) { if (fontFlagsHasLayout) { return fontAdvanceTable.get(glyphIndex); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 09e8921d7..02d83e6b6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -73,9 +73,9 @@ public class DefineFont3Tag extends FontTag { } @Override - public int getGlyphAdvance(int glyphIndex) { + public double getGlyphAdvance(int glyphIndex) { if (fontFlagsHasLayout) { - return fontAdvanceTable.get(glyphIndex) / 20; + return fontAdvanceTable.get(glyphIndex) / SWF.unitDivisor; } else { return -1; } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java index c9987c059..8f0c6d998 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java @@ -48,7 +48,7 @@ public class DefineFontTag extends FontTag { } @Override - public int getGlyphAdvance(int glyphIndex) { + public double getGlyphAdvance(int glyphIndex) { return -1; } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index 7dd6c9375..ec64e3930 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -20,6 +20,8 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; @@ -37,7 +39,6 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -189,7 +190,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { List finalRecords = new ArrayList<>(); FILLSTYLEARRAY fillStyles = morphFillStyles.getFillStylesAt(frame); LINESTYLEARRAY lineStyles = morphLineStyles.getLineStylesAt(getShapeNum(), frame); @@ -272,8 +273,8 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { return new Point( - (startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / 20, - (startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / 20); + (startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / SWF.unitDivisor, + (startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index a07471be9..1ec729272 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -20,6 +20,8 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; @@ -37,7 +39,6 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -176,7 +177,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { List finalRecords = new ArrayList<>(); FILLSTYLEARRAY fillStyles = morphFillStyles.getFillStylesAt(frame); LINESTYLEARRAY lineStyles = morphLineStyles.getLineStylesAt(getShapeNum(), frame); @@ -259,8 +260,8 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { return new Point( - (startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / 20, - (startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / 20); + (startBounds.Xmin + (endBounds.Xmin - startBounds.Xmin) * frame / 65535) / SWF.unitDivisor, + (startBounds.Ymin + (endBounds.Ymin - startBounds.Ymin) * frame / 65535) / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java index 3b445e40b..0ad42fc5a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java @@ -19,6 +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.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -26,7 +28,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; @@ -43,7 +44,7 @@ public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTa @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { - return new Point(shapeBounds.Xmin / 20, shapeBounds.Ymin / 20); + return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor); } @Override @@ -69,10 +70,8 @@ public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTa } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - BitmapExporter exporter = new BitmapExporter(swf, getShapes()); - exporter.export(); - return exporter.getImage(); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return BitmapExporter.export(swf, getShapes()); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index b29ed1a5b..aa5246c59 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -19,6 +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.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -26,7 +28,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; @@ -43,7 +44,7 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTa @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { - return new Point(shapeBounds.Xmin / 20, shapeBounds.Ymin / 20); + return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor); } @Override @@ -74,10 +75,8 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTa } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - BitmapExporter exporter = new BitmapExporter(swf, getShapes()); - exporter.export(); - return exporter.getImage(); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return BitmapExporter.export(swf, getShapes()); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index 7e2211a35..2acb98145 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -19,6 +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.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -26,7 +28,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; @@ -47,7 +48,7 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTa @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { - return new Point(shapeBounds.Xmin / 20, shapeBounds.Ymin / 20); + return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor); } @Override @@ -73,10 +74,8 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTa } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - BitmapExporter exporter = new BitmapExporter(swf, getShapes()); - exporter.export(); - return exporter.getImage(); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return BitmapExporter.export(swf, getShapes()); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index d8b3395dc..a67760884 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -20,6 +20,8 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -27,7 +29,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -103,15 +104,13 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, ShapeTag } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - BitmapExporter exporter = new BitmapExporter(swf, getShapes()); - exporter.export(); - return exporter.getImage(); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return BitmapExporter.export(swf, getShapes()); } @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { - return new Point(shapeBounds.Xmin / 20, shapeBounds.Ymin / 20); + return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 318ca2cb0..5441d138a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -21,6 +21,8 @@ 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.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.Container; @@ -31,7 +33,6 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.awt.geom.AffineTransform; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -150,19 +151,19 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT if (m != null) { AffineTransform trans = SWF.matrixToTransform(m); - Point topleft = new Point(); - trans.transform(new Point(r.Xmin, r.Ymin), topleft); - Point topright = new Point(); - trans.transform(new Point(r.Xmax, r.Ymin), topright); - Point bottomright = new Point(); - trans.transform(new Point(r.Xmax, r.Ymax), bottomright); - Point bottomleft = new Point(); - trans.transform(new Point(r.Xmin, r.Ymax), bottomleft); + java.awt.Point topleft = new java.awt.Point(); + trans.transform(new java.awt.Point(r.Xmin, r.Ymin), topleft); + java.awt.Point topright = new java.awt.Point(); + trans.transform(new java.awt.Point(r.Xmax, r.Ymin), topright); + java.awt.Point bottomright = new java.awt.Point(); + trans.transform(new java.awt.Point(r.Xmax, r.Ymax), bottomright); + java.awt.Point bottomleft = new java.awt.Point(); + trans.transform(new java.awt.Point(r.Xmin, r.Ymax), bottomleft); - r.Xmin = Math.min(Math.min(Math.min(topleft.x, topright.x), bottomleft.x), bottomright.x); - r.Ymin = Math.min(Math.min(Math.min(topleft.y, topright.y), bottomleft.y), bottomright.y); - r.Xmax = Math.max(Math.max(Math.max(topleft.x, topright.x), bottomleft.x), bottomright.x); - r.Ymax = Math.max(Math.max(Math.max(topleft.y, topright.y), bottomleft.y), bottomright.y); + r.Xmin = (int) Math.min(Math.min(Math.min(topleft.x, topright.x), bottomleft.x), bottomright.x); + r.Ymin = (int) Math.min(Math.min(Math.min(topleft.y, topright.y), bottomleft.y), bottomright.y); + r.Xmax = (int) Math.max(Math.max(Math.max(topleft.x, topright.x), bottomleft.x), bottomright.x); + r.Ymax = (int) Math.max(Math.max(Math.max(topleft.y, topright.y), bottomleft.y), bottomright.y); } ret.Xmin = Math.min(r.Xmin, ret.Xmin); @@ -271,7 +272,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { if (visited.contains(spriteId)) { return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR); } @@ -284,7 +285,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT SWF.fixRect(rect);*/ RECT rect = getRect(characters, visited); visited.push(spriteId); - SerializableImage ret = SWF.frameToImage(spriteId, frame, tags, subTags, rect, frameCount, visited); + SerializableImage ret = SWF.frameToImage(spriteId, frame, tags, subTags, rect, frameCount, visited, transformation); visited.pop(); return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index bdfa32dc6..10ca097c2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -19,6 +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.Matrix; +import com.jpexs.decompiler.flash.exporters.Point; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -34,7 +36,6 @@ import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.TEXTRECORD; import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -376,7 +377,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag { } advance = (int) Math.round(font.getDivider() * Math.round((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0))); } else { - advance = (int) Math.round(20.0 * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), textHeight / 20, c, nextChar)); + advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor), c, nextChar)); } tr.glyphEntries[i].glyphAdvance = advance; @@ -488,8 +489,8 @@ public class DefineText2Tag extends TextTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - return staticTextToImage(swf, characters, textRecords, textBounds, 2); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return staticTextToImage(swf, characters, textRecords, textBounds, 2, transformation); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 773c111b7..a89940b1e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -20,6 +20,8 @@ import com.jpexs.decompiler.flash.AppStrings; 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.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -35,7 +37,6 @@ import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.TEXTRECORD; import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -382,7 +383,7 @@ public class DefineTextTag extends TextTag implements DrawableTag { } advance = (int) Math.round(font.getDivider() * Math.round((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0))); } else { - advance = (int) Math.round(20.0 * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), textHeight / 20, c, nextChar)); + advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor), c, nextChar)); } tr.glyphEntries[i].glyphAdvance = advance; @@ -504,13 +505,13 @@ public class DefineTextTag extends TextTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { - return staticTextToImage(swf, characters, textRecords, textBounds, 1); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { + return staticTextToImage(swf, characters, textRecords, textBounds, 1, transformation); } @Override public Point getImagePos(int frame, HashMap characters, Stack visited) { - return new Point(textBounds.Xmin / 20, textBounds.Ymin / 20); + return new Point(textBounds.Xmin / SWF.unitDivisor, textBounds.Ymin / SWF.unitDivisor); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java index c79fbd8e5..1bd7a0398 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java @@ -101,6 +101,6 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag { @Override public RECT getRect(HashMap characters, Stack visited) { - return new RECT(0, 20 * width, 0, 20 * height); + return new RECT(0, (int) (SWF.unitDivisor * width), 0, (int) (SWF.unitDivisor * height)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java index a1a816d5f..5d1e8a186 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java @@ -16,9 +16,10 @@ */ 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.tags.Tag; import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -29,7 +30,7 @@ import java.util.Stack; */ public interface DrawableTag { - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited); + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation); public Point getImagePos(int frame, HashMap characters, Stack visited); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index ec4312a58..4b09c310a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -18,6 +18,8 @@ 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.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; @@ -29,7 +31,6 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.Font; -import java.awt.Point; import java.awt.font.FontRenderContext; import java.awt.font.GlyphMetrics; import java.awt.font.GlyphVector; @@ -60,7 +61,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable public abstract int charToGlyph(List tags, char c); - public abstract int getGlyphAdvance(int glyphIndex); + public abstract double getGlyphAdvance(int glyphIndex); public abstract int getGlyphKerningAdjustment(List tags, int glyphIndex, int nextGlyphIndex); @@ -246,7 +247,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index c3ffb9bb1..df6cd6d19 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.Matrix; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.text.ParseException; import com.jpexs.decompiler.flash.types.GLYPHENTRY; @@ -120,7 +121,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { if (!font.hasLayout()) { String fontName = FontTag.getFontNameWithFallback(font.getFontName()); - aFont = new Font(fontName, font.getFontStyle(), textHeight / 20); + aFont = new Font(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor)); fontMetrics = bi.getGraphics().getFontMetrics(aFont); LineMetrics lm = fontMetrics.getLineMetrics("A", bi.getGraphics()); ascent = lm.getAscent(); @@ -128,9 +129,9 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { leading = lm.getLeading(); lineDistance = ascent + descent; } else { - leading = ((double) font.getLeading() * textHeight / 1024.0 / font.getDivider() / 20.0); - ascent = ((double) font.getAscent() * textHeight / 1024.0 / font.getDivider() / 20.0); - descent = ((double) font.getDescent() * textHeight / 1024.0 / font.getDivider() / 20.0); + leading = ((double) font.getLeading() * textHeight / 1024.0 / font.getDivider() / SWF.unitDivisor); + ascent = ((double) font.getAscent() * textHeight / 1024.0 / font.getDivider() / SWF.unitDivisor); + descent = ((double) font.getDescent() * textHeight / 1024.0 / font.getDivider() / SWF.unitDivisor); lineDistance = ascent + descent; } @@ -143,9 +144,9 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { if (rec.styleFlagsHasYOffset) { if (!firstLine) { top += lineDistance; - int topint = 20 * (int) Math.round(top); + int topint = (int) Math.round(SWF.unitDivisor * top); lineSpacing = rec.yOffset - topint; - top += ((double) lineSpacing) / 20; + top += lineSpacing / SWF.unitDivisor; } else { top = ascent - 2.0; //I don't know why, but there are always 2 pixels } @@ -175,9 +176,9 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { if (nextEntry != null) { kerningAdjustment = font.getGlyphKerningAdjustment(tags, entry.glyphIndex, nextEntry.glyphIndex); } - defaultAdvance = (int) Math.round((double) 20.0 * textHeight * (font.getGlyphAdvance(entry.glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)); + defaultAdvance = (int) Math.round(SWF.unitDivisor * textHeight * (font.getGlyphAdvance(entry.glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)); } else { - defaultAdvance = (int) Math.round(20.0 * FontTag.getSystemFontAdvance(aFont, font.glyphToChar(tags, entry.glyphIndex), nextEntry == null ? null : font.glyphToChar(tags, nextEntry.glyphIndex))); + defaultAdvance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(aFont, font.glyphToChar(tags, entry.glyphIndex), nextEntry == null ? null : font.glyphToChar(tags, nextEntry.glyphIndex))); } letterSpacing = adv - defaultAdvance; x += adv; @@ -193,8 +194,8 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { return att; } - public static SerializableImage staticTextToImage(SWF swf, HashMap characters, List textRecords, RECT textBounds, int numText) { - float unzoom = 20; + public static SerializableImage staticTextToImage(SWF swf, HashMap characters, List textRecords, RECT textBounds, int numText, Matrix transformation) { + double unzoom = SWF.unitDivisor; double fixX = -textBounds.Xmin / unzoom; double fixY = -textBounds.Ymin / unzoom; double width = textBounds.getWidth() / unzoom; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java b/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index 98e3074ea..eed9fc3f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -19,6 +19,8 @@ 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.Matrix; +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.CharacterTag; @@ -43,7 +45,6 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.Font; -import java.awt.Point; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -117,13 +118,13 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited) { + public SerializableImage toImage(int frame, List tags, HashMap characters, Stack visited, Matrix transformation) { if (imageCache.contains("font" + fontId)) { return ((SerializableImage) imageCache.get("font" + fontId)); } List shapes = new ArrayList<>(); for (int i = 0; i < shapeCache.size(); i++) { - shapes.add(SHAPERECORD.resizeSHAPE(shapeCache.get(i), 20)); + shapes.add(SHAPERECORD.resizeSHAPE(shapeCache.get(i), SWF.unitDivisor)); } int cols = (int) Math.ceil(Math.sqrt(shapes.size())); int size = 500; @@ -176,7 +177,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { public void addCharacter(List tags, char character, String fontName) { int fontStyle = getFontStyle(); FontType font = fonts.get(0); - SHAPE shp = SHAPERECORD.systemFontCharacterToSHAPE(fontName, fontStyle, 20 * font.nominalSize, character); + SHAPE shp = SHAPERECORD.systemFontCharacterToSHAPE(fontName, fontStyle, (int) (SWF.unitDivisor * font.nominalSize), character); int code = (int) character; int pos = -1; @@ -229,7 +230,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { } @Override - public int getGlyphAdvance(int glyphIndex) { + public double getGlyphAdvance(int glyphIndex) { return fonts.get(0).glyphInfo.get(glyphIndex).advanceX; } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index b27574056..63e9511b9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -134,8 +134,8 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali maxh = r.getHeight(); } } - maxw /= 20; - maxh /= 20; + maxw /= SWF.unitDivisor; + maxh /= SWF.unitDivisor; int cols = (int) Math.ceil(Math.sqrt(shapes.size())); int pos = 0; @@ -369,7 +369,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali return new Point2D.Double(x, y); } - public static SHAPE resizeSHAPE(SHAPE shp, int multiplier) { + public static SHAPE resizeSHAPE(SHAPE shp, double multiplier) { SHAPE ret = new SHAPE(); ret.numFillBits = shp.numFillBits; ret.numLineBits = shp.numLineBits; @@ -378,22 +378,22 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali SHAPERECORD c = (SHAPERECORD) Helper.deepCopy(r); if (c instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) c; - scr.moveDeltaX = (multiplier * scr.moveDeltaX); - scr.moveDeltaY = (multiplier * scr.moveDeltaY); + scr.moveDeltaX = (int) (multiplier * scr.moveDeltaX); + scr.moveDeltaY = (int) (multiplier * scr.moveDeltaY); scr.calculateBits(); } if (c instanceof CurvedEdgeRecord) { CurvedEdgeRecord cer = (CurvedEdgeRecord) c; - cer.controlDeltaX = (multiplier * cer.controlDeltaX); - cer.controlDeltaY = (multiplier * cer.controlDeltaY); - cer.anchorDeltaX = (multiplier * cer.anchorDeltaX); - cer.anchorDeltaY = (multiplier * cer.anchorDeltaY); + cer.controlDeltaX = (int) (multiplier * cer.controlDeltaX); + cer.controlDeltaY = (int) (multiplier * cer.controlDeltaY); + cer.anchorDeltaX = (int) (multiplier * cer.anchorDeltaX); + cer.anchorDeltaY = (int) (multiplier * cer.anchorDeltaY); cer.calculateBits(); } if (c instanceof StraightEdgeRecord) { StraightEdgeRecord ser = (StraightEdgeRecord) c; - ser.deltaX = (multiplier * ser.deltaX); - ser.deltaY = (multiplier * ser.deltaY); + ser.deltaX = (int) (multiplier * ser.deltaX); + ser.deltaY = (int) (multiplier * ser.deltaY); ser.calculateBits(); } recs.add(c);