mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-23 06:05:34 +00:00
image rendering fixed
This commit is contained in:
@@ -2136,7 +2136,8 @@ 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, mat, characters, visited);
|
||||
SerializableImage img = drawable.toImage(layer.ratio < 0 ? 0 : layer.ratio/*layer.duration*/, allTags, characters, visited);
|
||||
mat.translate(img.bounds.getMinX(), img.bounds.getMinY());
|
||||
/*if (character instanceof BoundedTag) {
|
||||
BoundedTag bounded = (BoundedTag) character;
|
||||
RECT rect = bounded.getRect(characters, visited);
|
||||
|
||||
@@ -43,6 +43,7 @@ import java.awt.Stroke;
|
||||
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;
|
||||
@@ -58,15 +59,13 @@ import javax.imageio.ImageIO;
|
||||
public class BitmapExporter extends ShapeExporterBase implements IShapeExporter {
|
||||
|
||||
private static final Cache<SerializableImage> cache = Cache.getInstance(false);
|
||||
private static final Cache<Double> cacheDeltaX = Cache.getInstance(false);
|
||||
private static final Cache<Double> cacheDeltaY = Cache.getInstance(false);
|
||||
|
||||
private SerializableImage image;
|
||||
private Graphics2D graphics;
|
||||
private final Color defaultColor;
|
||||
private final boolean putToCache;
|
||||
public double deltaX;
|
||||
public double deltaY;
|
||||
private double deltaX;
|
||||
private double deltaY;
|
||||
private final SWF swf;
|
||||
private GeneralPath path;
|
||||
private Paint fillPathPaint;
|
||||
@@ -79,15 +78,8 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
static int imageid = 0;
|
||||
|
||||
public static SerializableImage export(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache) {
|
||||
return export(swf, shape, defaultColor, putToCache, null);
|
||||
}
|
||||
|
||||
public static SerializableImage export(SWF swf, SHAPE shape, Color defaultColor, boolean putToCache, Matrix matrix) {
|
||||
BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor, putToCache);
|
||||
exporter.export();
|
||||
if (matrix != null) {
|
||||
matrix.translate(exporter.deltaX, exporter.deltaY);
|
||||
}
|
||||
return exporter.getImage();
|
||||
}
|
||||
|
||||
@@ -116,8 +108,6 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
String key = "shape_" + records.hashCode() + "_" + (defaultColor == null ? "null" : defaultColor.hashCode());
|
||||
if (cache.contains(key)) {
|
||||
image = (SerializableImage) cache.get(key);
|
||||
deltaX = (double) cacheDeltaX.get(key);
|
||||
deltaY = (double) cacheDeltaY.get(key);
|
||||
return;
|
||||
}
|
||||
RECT bounds = SHAPERECORD.getBounds(records);
|
||||
@@ -133,8 +123,9 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
double maxLineWidth = maxLineWidthTwips / unitDivisor / 2;
|
||||
deltaX = bounds.Xmin / unitDivisor - maxLineWidth;
|
||||
deltaY = bounds.Ymin / unitDivisor - maxLineWidth;
|
||||
image = new SerializableImage(
|
||||
(int) (bounds.getWidth() / unitDivisor + 2 + maxLineWidth), (int) (bounds.getHeight() / unitDivisor + 2 + maxLineWidth), SerializableImage.TYPE_INT_ARGB);
|
||||
double width = bounds.getWidth() / unitDivisor + 2 * (maxLineWidth + 1);
|
||||
double height = bounds.getHeight() / 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);
|
||||
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
@@ -146,10 +137,9 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
} 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);
|
||||
cacheDeltaX.put(key, deltaX);
|
||||
cacheDeltaY.put(key, deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
Matrix mat = new Matrix();
|
||||
mat.translateX = swf.displayRect.Xmin;
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
setImage(drawable.toImage(0, swf.tags, mat, characters, new Stack<Integer>()));
|
||||
SerializableImage img = drawable.toImage(0, swf.tags, characters, new Stack<Integer>());
|
||||
mat.translate(img.bounds.getMinX(), img.bounds.getMinY());
|
||||
setImage(img);
|
||||
return;
|
||||
}
|
||||
play();
|
||||
@@ -178,7 +180,9 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
Matrix mat = new Matrix();
|
||||
mat.translateX = swf.displayRect.Xmin;
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
ImageIcon icon = new ImageIcon(drawable.toImage(nframe, swf.tags, mat, characters, new Stack<Integer>()).getBufferedImage());
|
||||
SerializableImage img = drawable.toImage(nframe, swf.tags, characters, new Stack<Integer>());
|
||||
mat.translate(img.bounds.getMinX(), img.bounds.getMinY());
|
||||
ImageIcon icon = new ImageIcon(img.getBufferedImage());
|
||||
label.setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,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.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -243,7 +242,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix mat, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
if (visited.contains(buttonId)) {
|
||||
return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,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.Matrix;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
@@ -266,7 +265,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
if (visited.contains(buttonId)) {
|
||||
return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR);
|
||||
}
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
@@ -190,7 +189,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
List<SHAPERECORD> finalRecords = new ArrayList<>();
|
||||
FILLSTYLEARRAY fillStyles = morphFillStyles.getFillStylesAt(frame);
|
||||
LINESTYLEARRAY lineStyles = morphLineStyles.getLineStylesAt(getShapeNum(), frame);
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
@@ -177,7 +176,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
List<SHAPERECORD> finalRecords = new ArrayList<>();
|
||||
FILLSTYLEARRAY fillStyles = morphFillStyles.getFillStylesAt(frame);
|
||||
LINESTYLEARRAY lineStyles = morphLineStyles.getLineStylesAt(getShapeNum(), frame);
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -38,7 +37,7 @@ import java.util.Stack;
|
||||
public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTag {
|
||||
|
||||
public int shapeId;
|
||||
private RECT shapeBounds;
|
||||
private final RECT shapeBounds;
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 22;
|
||||
|
||||
@@ -70,10 +69,9 @@ public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
BitmapExporter exporter = new BitmapExporter(swf, getShapes());
|
||||
exporter.export();
|
||||
matrix.translate(exporter.deltaX, exporter.deltaY);
|
||||
return exporter.getImage();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -38,7 +37,7 @@ import java.util.Stack;
|
||||
public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTag {
|
||||
|
||||
public int shapeId;
|
||||
private RECT shapeBounds;
|
||||
private final RECT shapeBounds;
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 32;
|
||||
|
||||
@@ -75,10 +74,9 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
BitmapExporter exporter = new BitmapExporter(swf, getShapes());
|
||||
exporter.export();
|
||||
matrix.translate(exporter.deltaX, exporter.deltaY);
|
||||
return exporter.getImage();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -38,8 +37,8 @@ import java.util.Stack;
|
||||
public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTag {
|
||||
|
||||
public int shapeId;
|
||||
private RECT shapeBounds;
|
||||
private RECT edgeBounds;
|
||||
private final RECT shapeBounds;
|
||||
private final RECT edgeBounds;
|
||||
public boolean usesFillWindingRule;
|
||||
public boolean usesNonScalingStrokes;
|
||||
public boolean usesScalingStrokes;
|
||||
@@ -74,10 +73,9 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
BitmapExporter exporter = new BitmapExporter(swf, getShapes());
|
||||
exporter.export();
|
||||
matrix.translate(exporter.deltaX, exporter.deltaY);
|
||||
return exporter.getImage();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -40,7 +39,7 @@ import java.util.Stack;
|
||||
public class DefineShapeTag extends CharacterTag implements BoundedTag, ShapeTag {
|
||||
|
||||
public int shapeId;
|
||||
private RECT shapeBounds;
|
||||
private final RECT shapeBounds;
|
||||
public SHAPEWITHSTYLE shapes;
|
||||
public static final int ID = 2;
|
||||
|
||||
@@ -104,10 +103,9 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, ShapeTag
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
BitmapExporter exporter = new BitmapExporter(swf, getShapes());
|
||||
exporter.export();
|
||||
matrix.translate(exporter.deltaX, exporter.deltaY);
|
||||
return exporter.getImage();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
@@ -272,7 +271,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
if (visited.contains(spriteId)) {
|
||||
return new SerializableImage(1, 1, SerializableImage.TYPE_4BYTE_ABGR);
|
||||
}
|
||||
|
||||
@@ -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.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
@@ -489,8 +488,8 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return staticTextToImage(swf, characters, textRecords, textBounds, matrix, 2);
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return staticTextToImage(swf, characters, textRecords, textBounds, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ 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.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
@@ -505,8 +504,8 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return staticTextToImage(swf, characters, textRecords, textBounds, matrix, 1);
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return staticTextToImage(swf, characters, textRecords, textBounds, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Point;
|
||||
@@ -30,7 +29,7 @@ import java.util.Stack;
|
||||
*/
|
||||
public interface DrawableTag {
|
||||
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited);
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited);
|
||||
|
||||
public Point getImagePos(int frame, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited);
|
||||
|
||||
|
||||
@@ -18,7 +18,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.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineTextTag;
|
||||
@@ -247,7 +246,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ 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;
|
||||
@@ -35,6 +34,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -193,12 +193,14 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
|
||||
return att;
|
||||
}
|
||||
|
||||
public static SerializableImage staticTextToImage(SWF swf, HashMap<Integer, CharacterTag> characters, List<TEXTRECORD> textRecords, RECT textBounds, Matrix matrix, int numText) {
|
||||
public static SerializableImage staticTextToImage(SWF swf, HashMap<Integer, CharacterTag> characters, List<TEXTRECORD> textRecords, RECT textBounds, int numText) {
|
||||
float unzoom = 20;
|
||||
double fixX = -textBounds.Xmin / unzoom;
|
||||
double fixY = -textBounds.Ymin / unzoom;
|
||||
matrix.translate(-fixX, -fixY);
|
||||
SerializableImage ret = new SerializableImage(textBounds.getWidth() / 20, textBounds.getHeight() / 20, SerializableImage.TYPE_INT_ARGB);
|
||||
double width = textBounds.getWidth() / unzoom;
|
||||
double height = textBounds.getHeight() / unzoom;
|
||||
SerializableImage ret = new SerializableImage((int) width, (int) height, SerializableImage.TYPE_INT_ARGB);
|
||||
ret.bounds = new Rectangle2D.Double(-fixX, -fixY, width, height);
|
||||
|
||||
Color textColor = new Color(0, 0, 0);
|
||||
FontTag font = null;
|
||||
@@ -232,16 +234,15 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
|
||||
|
||||
for (GLYPHENTRY entry : rec.glyphEntries) {
|
||||
// shapeNum: 1
|
||||
Matrix matrix2 = new Matrix();
|
||||
SerializableImage img = BitmapExporter.export(swf, glyphs.get(entry.glyphIndex), textColor, true, matrix2);
|
||||
SHAPE shape = glyphs.get(entry.glyphIndex);
|
||||
SerializableImage img = BitmapExporter.export(swf, shape, textColor, true);
|
||||
AffineTransform tr = new AffineTransform();
|
||||
tr.setToIdentity();
|
||||
float rat = textHeight / 1024f;
|
||||
tr.translate(x / unzoom + matrix2.translateX + fixX, y / unzoom + rat * matrix2.translateY + fixY);
|
||||
double rat = (double) textHeight / 1000.0;
|
||||
tr.translate(x / unzoom + img.bounds.getMinX() * rat + fixX, y / unzoom + img.bounds.getMinY() * rat + fixY);
|
||||
tr.scale(1.0 / font.getDivider(), 1.0 / font.getDivider());
|
||||
tr.scale(rat, rat);
|
||||
g.drawImage(img.getBufferedImage(), tr, null);
|
||||
x += entry.glyphAdvance;
|
||||
x += (int) entry.glyphAdvance;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -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.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFont2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
@@ -118,7 +117,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, Matrix matrix, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
public SerializableImage toImage(int frame, List<Tag> tags, HashMap<Integer, CharacterTag> characters, Stack<Integer> visited) {
|
||||
if (imageCache.contains("font" + fontId)) {
|
||||
return ((SerializableImage) imageCache.get("font" + fontId));
|
||||
}
|
||||
|
||||
@@ -18,26 +18,16 @@
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.TileObserver;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
@@ -52,6 +42,7 @@ public class SerializableImage implements Serializable {
|
||||
public static int TYPE_4BYTE_ABGR = BufferedImage.TYPE_4BYTE_ABGR;
|
||||
|
||||
private BufferedImage image;
|
||||
public Rectangle2D bounds = new Rectangle2D.Double();
|
||||
|
||||
public SerializableImage() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user