diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 9677666cb..8f070d918 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -2061,9 +2061,19 @@ public final class SWF implements TreeItem { private static Cache frameCache = Cache.getInstance(false); - public void clearImageCache() { + public static SerializableImage getFromCache(String key) { + if (frameCache.contains(key)) { + return (SerializableImage) SWF.frameCache.get(key); + } + return null; + } + + public static void putToCache(String key, SerializableImage img) { + frameCache.put(key, img); + } + + public static void clearImageCache() { frameCache.clear(); - BitmapExporter.clearShapeCache(); } public static RECT fixRect(RECT rect) { @@ -2107,14 +2117,14 @@ public final class SWF implements TreeItem { } 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; + int fixX = -displayRect.Xmin; + int fixY = -displayRect.Ymin; + int width = displayRect.getWidth(); + int height = displayRect.getHeight(); 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); + SerializableImage ret = new SerializableImage((int) (width / unzoom), (int) (height / unzoom), SerializableImage.TYPE_INT_ARGB); + ret.bounds = new Rectangle2D.Double(-fixX / unzoom, -fixY / unzoom, width / unzoom, height / unzoom); Graphics2D g = (Graphics2D) ret.getGraphics(); g.setPaint(backgroundColor); @@ -2144,12 +2154,7 @@ public final class SWF implements TreeItem { if (character instanceof DrawableTag) { DrawableTag drawable = (DrawableTag) character; 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()); + mat.translate(img.bounds.getMinX() * unzoom, img.bounds.getMinY() * unzoom); /*if (character instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) character; RECT rect = bounded.getRect(characters, visited); @@ -2215,10 +2220,14 @@ public final class SWF implements TreeItem { break; } + mat.translateX /= unzoom; + mat.translateY /= unzoom; AffineTransform trans = mat.toTransform(); g.setTransform(trans); g.drawImage(img.getBufferedImage(), 0, 0, null); } else if (character instanceof BoundedTag) { + mat.translateX /= unzoom; + mat.translateY /= unzoom; AffineTransform trans = mat.toTransform(); g.setTransform(trans); BoundedTag b = (BoundedTag) character; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java index 1a1feeac6..f5a08d722 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java @@ -44,13 +44,8 @@ import java.awt.TexturePaint; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.ImageIO; /** * @@ -58,12 +53,9 @@ import javax.imageio.ImageIO; */ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter { - private static final Cache cache = Cache.getInstance(false); - private SerializableImage image; private Graphics2D graphics; private final Color defaultColor; - private final boolean putToCache; private double deltaX; private double deltaY; private final SWF swf; @@ -74,36 +66,28 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter private Color lineColor; private Stroke lineStroke; private Stroke defaultStroke; - - static int imageid = 0; public static SerializableImage export(SWF swf, SHAPE shape) { - BitmapExporter exporter = new BitmapExporter(swf, shape, null, true); + BitmapExporter exporter = new BitmapExporter(swf, shape, null); 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); + BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor); exporter.export(); return exporter.getImage(); } - private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache) { + private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor) { super(shape); this.swf = swf; this.defaultColor = defaultColor; - this.putToCache = putToCache; } @Override public void export() { List records = shape.shapeRecords; - String key = "shape_" + records.hashCode() + "_" + (defaultColor == null ? "null" : defaultColor.hashCode()); - if (cache.contains(key)) { - image = (SerializableImage) cache.get(key); - return; - } RECT bounds = SHAPERECORD.getBounds(records); int maxLineWidthTwips = 0; if (shape instanceof SHAPEWITHSTYLE) { @@ -126,25 +110,13 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); defaultStroke = graphics.getStroke(); super.export(); - try { - ImageIO.write(image.getBufferedImage(), "png", new File("c:\\10\\imageid" + imageid ++ + ".png")); - } catch (IOException ex) { - Logger.getLogger(BitmapExporter.class.getName()).log(Level.SEVERE, null, ex); - } image.bounds = new Rectangle2D.Double(deltaX, deltaY, width, height); - if (putToCache) { - cache.put(key, image); - } } public SerializableImage getImage() { return image; } - public static void clearShapeCache() { - cache.clear(); - } - @Override public void beginShape() { } @@ -179,6 +151,12 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter @Override public void beginGradientFill(int type, GRADRECORD[] gradientRecords, Matrix matrix, int spreadMethod, int interpolationMethod, float focalPointRatio) { finalizePath(); + matrix.translateX /= SWF.unitDivisor; + matrix.translateY /= SWF.unitDivisor; + matrix.scaleX /= SWF.unitDivisor; + matrix.scaleY /= SWF.unitDivisor; + matrix.rotateSkew0 /= SWF.unitDivisor; + matrix.rotateSkew1 /= SWF.unitDivisor; switch (type) { case FILLSTYLE.LINEAR_GRADIENT: { List colors = new ArrayList<>(); @@ -287,6 +265,12 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter @Override public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth) { finalizePath(); + matrix.translateX /= SWF.unitDivisor; + matrix.translateY /= SWF.unitDivisor; + matrix.scaleX /= SWF.unitDivisor; + matrix.scaleY /= SWF.unitDivisor; + matrix.rotateSkew0 /= SWF.unitDivisor; + matrix.rotateSkew1 /= SWF.unitDivisor; ImageTag image = null; for (Tag t : swf.tags) { if (t instanceof ImageTag) { @@ -317,6 +301,7 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter @Override public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, int miterLimit) { finalizePath(); + thickness /= SWF.unitDivisor; lineColor = color.toColor(); int capStyle = BasicStroke.CAP_ROUND; switch (startCaps) { @@ -355,17 +340,18 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter @Override public void moveTo(double x, double y) { - path.moveTo(x - deltaX, y - deltaY); + path.moveTo(x / SWF.unitDivisor - deltaX, y / SWF.unitDivisor - deltaY); } @Override public void lineTo(double x, double y) { - path.lineTo(x - deltaX, y - deltaY); + path.lineTo(x / SWF.unitDivisor - deltaX, y / SWF.unitDivisor - deltaY); } @Override public void curveTo(double controlX, double controlY, double anchorX, double anchorY) { - path.quadTo(controlX - deltaX, controlY - deltaY, anchorX - deltaX, anchorY - deltaY); + path.quadTo(controlX / SWF.unitDivisor - deltaX, controlY / SWF.unitDivisor - deltaY, + anchorX / SWF.unitDivisor - deltaX, anchorY / SWF.unitDivisor - deltaY); } protected void finalizePath() { diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java index 5b265caf0..204f14e91 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.SHAPE; @@ -94,8 +95,8 @@ public class DefaultSVGShapeExporter extends ShapeExporterBase implements IShape public void moveTo(double x, double y) { currentDrawCommand = ""; pathData += "M" - + roundPixels20(x) + " " - + roundPixels20(y) + " "; + + roundPixels20(x / SWF.unitDivisor) + " " + + roundPixels20(y / SWF.unitDivisor) + " "; } @Override @@ -104,8 +105,8 @@ public class DefaultSVGShapeExporter extends ShapeExporterBase implements IShape currentDrawCommand = DRAW_COMMAND_L; pathData += "L"; } - pathData += roundPixels20(x) + " " - + roundPixels20(y) + " "; + pathData += roundPixels20(x / SWF.unitDivisor) + " " + + roundPixels20(y / SWF.unitDivisor) + " "; } @Override @@ -114,14 +115,22 @@ public class DefaultSVGShapeExporter extends ShapeExporterBase implements IShape currentDrawCommand = DRAW_COMMAND_Q; pathData += "Q"; } - pathData += roundPixels20(controlX) + " " - + roundPixels20(controlY) + " " - + roundPixels20(anchorX) + " " - + roundPixels20(anchorY) + " "; + pathData += roundPixels20(controlX / SWF.unitDivisor) + " " + + roundPixels20(controlY / SWF.unitDivisor) + " " + + roundPixels20(anchorX / SWF.unitDivisor) + " " + + roundPixels20(anchorY / SWF.unitDivisor) + " "; } protected void finalizePath() { pathData = ""; currentDrawCommand = ""; } + + protected double roundPixels20(double pixels) { + return Math.round(pixels * 100) / 100.0; + } + + protected double roundPixels400(double pixels) { + return Math.round(pixels * 10000) / 10000.0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java index a38319892..e2e861242 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java @@ -45,15 +45,18 @@ public class Matrix { } public Matrix(MATRIX matrix) { - translateX = matrix.translateX / SWF.unitDivisor; - translateY = matrix.translateY / SWF.unitDivisor; + translateX = matrix.translateX; + translateY = matrix.translateY; if (matrix.hasScale) { - scaleX = matrix.getScaleXFloat() / SWF.unitDivisor; - scaleY = matrix.getScaleYFloat() / SWF.unitDivisor; + scaleX = matrix.getScaleXFloat(); + scaleY = matrix.getScaleYFloat(); + } else { + scaleX = 1; + scaleY = 1; } if (matrix.hasRotate) { - rotateSkew0 = matrix.getRotateSkew0Float() / SWF.unitDivisor; - rotateSkew1 = matrix.getRotateSkew1Float() / SWF.unitDivisor; + rotateSkew0 = matrix.getRotateSkew0Float(); + rotateSkew1 = matrix.getRotateSkew1Float(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java index 9befa30a4..60695ef81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java @@ -115,10 +115,10 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { @Override public void endShape(double xMin, double yMin, double xMax, double yMax) { - xMin -= maxLineWidth; - xMax += maxLineWidth; - yMin -= maxLineWidth; - yMax += maxLineWidth; + xMin /= SWF.unitDivisor; + yMin /= SWF.unitDivisor; + xMin -= maxLineWidth / SWF.unitDivisor; + yMin -= maxLineWidth / SWF.unitDivisor; _svgG.setAttribute("transform", "matrix(1, 0, 0, 1, " + roundPixels20(-xMin) + ", " + roundPixels20(-yMin) + ")"); } @@ -198,12 +198,12 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { pattern.setAttribute("height", "" + height); pattern.setAttribute("viewBox", "0 0 " + width + " " + height); if (matrix != null) { - double translateX = roundPixels400(matrix.translateX); - double translateY = roundPixels400(matrix.translateY); - double rotateSkew0 = roundPixels400(matrix.rotateSkew0); - double rotateSkew1 = roundPixels400(matrix.rotateSkew1); - double scaleX = roundPixels400(matrix.scaleX); - double scaleY = roundPixels400(matrix.scaleY); + double translateX = roundPixels400(matrix.translateX / SWF.unitDivisor); + double translateY = roundPixels400(matrix.translateY / SWF.unitDivisor); + double rotateSkew0 = roundPixels400(matrix.rotateSkew0 / SWF.unitDivisor); + double rotateSkew1 = roundPixels400(matrix.rotateSkew1 / SWF.unitDivisor); + double scaleX = roundPixels400(matrix.scaleX / SWF.unitDivisor); + double scaleY = roundPixels400(matrix.scaleY / SWF.unitDivisor); pattern.setAttribute("patternTransform", "matrix(" + scaleX + ", " + rotateSkew0 + ", " + rotateSkew1 + ", " + scaleY + ", " + translateX + ", " + translateY + ")"); } @@ -223,6 +223,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { if (thickness > maxLineWidth) { maxLineWidth = thickness; } + thickness /= SWF.unitDivisor; path.setAttribute("fill", "none"); path.setAttribute("stroke", color.toHexRGB()); path.setAttribute("stroke-width", Double.toString(thickness == 0 ? 1 : thickness)); @@ -317,12 +318,8 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { gradient.setAttribute("color-interpolation", "linearRGB"); } if (matrix != null) { - 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 translateX = roundPixels400(matrix.translateX / SWF.unitDivisor); + double translateY = roundPixels400(matrix.translateY / SWF.unitDivisor); double rotateSkew0 = roundPixels400(matrix.rotateSkew0); double rotateSkew1 = roundPixels400(matrix.rotateSkew1); double scaleX = roundPixels400(matrix.scaleX); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java index c1baf84de..1449c77cf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java @@ -16,7 +16,6 @@ */ 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; @@ -154,33 +153,33 @@ public abstract class ShapeExporterBase implements IShapeExporter { } } if (styleChangeRecord.stateMoveTo) { - xPos = styleChangeRecord.moveDeltaX / SWF.unitDivisor; - yPos = styleChangeRecord.moveDeltaY / SWF.unitDivisor; + xPos = styleChangeRecord.moveDeltaX; + yPos = styleChangeRecord.moveDeltaY; } } else if (shapeRecord instanceof StraightEdgeRecord) { StraightEdgeRecord straightEdgeRecord = (StraightEdgeRecord) shapeRecord; - from = new Point(roundPixels400(xPos), roundPixels400(yPos)); + from = new Point(xPos, yPos); if (straightEdgeRecord.generalLineFlag) { - xPos += straightEdgeRecord.deltaX / SWF.unitDivisor; - yPos += straightEdgeRecord.deltaY / SWF.unitDivisor; + xPos += straightEdgeRecord.deltaX; + yPos += straightEdgeRecord.deltaY; } else { if (straightEdgeRecord.vertLineFlag) { - yPos += straightEdgeRecord.deltaY / SWF.unitDivisor; + yPos += straightEdgeRecord.deltaY; } else { - xPos += straightEdgeRecord.deltaX / SWF.unitDivisor; + xPos += straightEdgeRecord.deltaX; } } - to = new Point(roundPixels400(xPos), roundPixels400(yPos)); + to = new Point(xPos, yPos); subPath.add(new StraightEdge(from, to, currentLineStyleIdx, currentFillStyleIdx1)); } else if (shapeRecord instanceof CurvedEdgeRecord) { CurvedEdgeRecord curvedEdgeRecord = (CurvedEdgeRecord) shapeRecord; - from = new Point(roundPixels400(xPos), roundPixels400(yPos)); - 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; + from = new Point(xPos, yPos); + double xPosControl = xPos + curvedEdgeRecord.controlDeltaX; + double yPosControl = yPos + curvedEdgeRecord.controlDeltaY; + xPos = xPosControl + curvedEdgeRecord.anchorDeltaX; + yPos = yPosControl + curvedEdgeRecord.anchorDeltaY; control = new Point(xPosControl, yPosControl); - to = new Point(roundPixels400(xPos), roundPixels400(yPos)); + to = new Point(xPos, yPos); subPath.add(new CurvedEdge(from, control, to, currentLineStyleIdx, currentFillStyleIdx1)); } else if (shapeRecord instanceof EndShapeRecord) { // We're done. Process the last subpath, if any @@ -371,7 +370,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { hasFillFlag = lineStyle2.hasFillFlag; } lineStyle( - lineStyle.width / SWF.unitDivisor, + lineStyle.width, lineStyle.color, pixelHintingFlag, scaleMode, @@ -522,12 +521,4 @@ public abstract class ShapeExporterBase implements IShapeExporter { v1.add(v2.get(i)); } } - - protected double roundPixels20(double pixels) { - return Math.round(pixels * 100) / 100.0; - } - - protected double roundPixels400(double pixels) { - return Math.round(pixels * 10000) / 10000.0; - } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index de4e93815..3ca5c569c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.Matrix; import com.jpexs.decompiler.flash.gui.player.FlashDisplay; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; +import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; import java.awt.BorderLayout; import java.awt.Color; @@ -124,7 +125,12 @@ 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(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + String key = "drawable_0_" + drawable.hashCode(); + SerializableImage img = SWF.getFromCache(key); + if (img == null) { + img = drawable.toImage(0, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + SWF.putToCache(key, img); + } mat.translate(img.bounds.getMinX(), img.bounds.getMinY()); setImage(img); return; @@ -180,7 +186,12 @@ 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(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + String key = "drawable_" + nframe + "_" + drawable.hashCode(); + SerializableImage img = SWF.getFromCache(key); + if (img == null) { + img = drawable.toImage(nframe, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + SWF.putToCache(key, img); + } 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/tags/gfx/DefineCompactedFont.java b/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index eed9fc3f5..846aabb9f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -68,7 +68,6 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { public int fontId; public List fonts; private List shapeCache; - private static final Cache imageCache = Cache.getInstance(false); /** * Gets data bytes @@ -119,9 +118,6 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { @Override 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), SWF.unitDivisor)); @@ -132,7 +128,6 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { size = cols * 30; } SerializableImage ret = SHAPERECORD.shapeListToImage(swf, shapes, size, size, Color.black); - imageCache.put("font" + fontId, ret); return ret; } @@ -210,7 +205,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { font.glyphs.set(pos, new GlyphType(shp.shapeRecords)); shapeCache.set(pos, font.glyphs.get(pos).toSHAPE()); } - imageCache.remove("font" + fontId); + SWF.clearImageCache(); } @Override diff --git a/trunk/src/com/jpexs/helpers/SerializableImage.java b/trunk/src/com/jpexs/helpers/SerializableImage.java index 3634e4df5..392035912 100644 --- a/trunk/src/com/jpexs/helpers/SerializableImage.java +++ b/trunk/src/com/jpexs/helpers/SerializableImage.java @@ -17,17 +17,21 @@ package com.jpexs.helpers; +import com.jpexs.decompiler.flash.exporters.BitmapExporter; import java.awt.Graphics; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; +import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Hashtable; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.imageio.ImageIO; /** @@ -41,6 +45,7 @@ public class SerializableImage implements Serializable { public static int TYPE_INT_ARGB_PRE = BufferedImage.TYPE_INT_ARGB_PRE; public static int TYPE_4BYTE_ABGR = BufferedImage.TYPE_4BYTE_ABGR; + static int imageid = 0; private BufferedImage image; public Rectangle2D bounds = new Rectangle2D.Double(); @@ -64,6 +69,11 @@ public class SerializableImage implements Serializable { } public BufferedImage getBufferedImage() { + /*try { + ImageIO.write(image, "png", new File("c:\\10\\x\\imageid" + String.format("%03d", imageid++) + ".png")); + } catch (IOException ex) { + Logger.getLogger(BitmapExporter.class.getName()).log(Level.SEVERE, null, ex); + }*/ return image; }