diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index e92fdcb02..09ea3ea47 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -2220,6 +2220,14 @@ public final class SWF implements TreeItem { RECT rect = displayRect; image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + //Make all pixels transparent + Graphics2D g = (Graphics2D)image.getGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(0,0,0,0f)); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, m); @@ -2357,6 +2365,14 @@ public final class SWF implements TreeItem { for (FrameInfo fi : frameInfos) { SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + //Make all pixels transparent + Graphics2D g = (Graphics2D)image.getGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(0,0,0,0f)); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, m); @@ -2410,6 +2426,14 @@ public final class SWF implements TreeItem { m.translate(-rect.xMin, -rect.yMin); drawMatrix.translate(rect.xMin, rect.yMin); } + //Make all pixels transparent + Graphics2D gr = (Graphics2D)img.getGraphics(); + gr.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + gr.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + gr.setComposite(AlphaComposite.Src); + gr.setColor(new Color(0,0,0,0f)); + gr.fillRect(0, 0, img.getWidth(), image.getHeight()); drawable.toImage(layer.ratio < 0 ? 0 : layer.ratio/*layer.duration*/, allTags, characters, visited, img, m); } else { // only DefineFont tags diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java index 44d106651..adaf718dc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java @@ -109,6 +109,11 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setComposite(AlphaComposite.Src); + + //Make all pixels transparent + graphics.setColor(new Color(0, 0, 0, 0f)); + graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); + defaultStroke = graphics.getStroke(); super.export(); } @@ -116,10 +121,6 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter private void exportTo(SerializableImage image, Matrix transformation) { this.image = image; graphics = (Graphics2D) image.getGraphics(); - graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setComposite(AlphaComposite.Src); AffineTransform at = transformation.toTransform(); at.preConcatenate(AffineTransform.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor)); unitDivisor = 1; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 8474c7702..ec8cf3d12 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -25,9 +25,14 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.SerializableImage; +import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Composite; import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; @@ -134,6 +139,14 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis RECT rect = bounded.getRect(characters, new Stack()); SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + //Make all pixels transparent + Graphics2D g = (Graphics2D) image.getGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(0, 0, 0, 0f)); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); drawable.toImage(0, swf.tags, characters, new Stack(), image, m); @@ -204,6 +217,14 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis RECT rect = bounded.getRect(characters, new Stack()); SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + //Make all pixels transparent + Graphics2D g = (Graphics2D) image.getGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(0, 0, 0, 0f)); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); drawable.toImage(nframe, swf.tags, characters, new Stack(), image, m); 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 73c45ebd8..bd5929b04 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -198,10 +198,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { int textHeight = 12; int x = 0; int y = 0; - Graphics2D g = (Graphics2D) image.getGraphics(); - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Graphics2D g = (Graphics2D) image.getGraphics(); List glyphs = new ArrayList<>(); for (TEXTRECORD rec : textRecords) { if (rec.styleFlagsHasColor) { 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 792358c81..e5e163d4d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -25,9 +25,11 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; +import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Shape; import java.awt.font.GlyphVector; import java.awt.geom.PathIterator; @@ -124,7 +126,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali public static SerializableImage shapeListToImage(SWF swf, List shapes, int prevWidth, int prevHeight, Color color) { if (shapes.isEmpty()) { - return new SerializableImage(1, 1, BufferedImage.TYPE_INT_RGB); + SerializableImage image = new SerializableImage(1, 1, BufferedImage.TYPE_INT_RGB); + //Make all pixels transparent + Graphics2D g = (Graphics2D)image.getGraphics(); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(0, 0, 0, 0f)); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); + return image; } SerializableImage ret = new SerializableImage(prevWidth, prevHeight, SerializableImage.TYPE_INT_ARGB); Graphics g = ret.getGraphics(); diff --git a/trunk/src/com/jpexs/helpers/SerializableImage.java b/trunk/src/com/jpexs/helpers/SerializableImage.java index d0f3b8164..067e4646e 100644 --- a/trunk/src/com/jpexs/helpers/SerializableImage.java +++ b/trunk/src/com/jpexs/helpers/SerializableImage.java @@ -41,6 +41,7 @@ public class SerializableImage implements Serializable { static int imageid = 0; private BufferedImage image; + private transient Graphics graphics; public SerializableImage() { } @@ -77,7 +78,11 @@ public class SerializableImage implements Serializable { } public Graphics getGraphics() { - return image.getGraphics(); + //One graphics rule them all + if (graphics != null) { + return graphics; + } + return graphics = image.getGraphics(); } public int getType() {