diff --git a/trunk/src/com/jpexs/decompiler/flash/Layer.java b/trunk/src/com/jpexs/decompiler/flash/Layer.java index f1a30e683..399f972f0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Layer.java +++ b/trunk/src/com/jpexs/decompiler/flash/Layer.java @@ -16,8 +16,7 @@ */ package com.jpexs.decompiler.flash; -import com.jpexs.decompiler.flash.types.CXFORM; -import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.filters.FILTER; @@ -32,8 +31,7 @@ public class Layer implements Serializable { public MATRIX matrix; public String instanceName = null; - public CXFORM colorTransForm = null; - public CXFORMWITHALPHA colorTransFormAlpha = null; + public ColorTransform colorTransForm = null; public boolean cacheAsBitmap = false; public int blendMode = 0; public List filters = null; @@ -43,5 +41,5 @@ public class Layer implements Serializable { public int ratio = -1; public int time = 0; public boolean visible = true; - public int clipDepth = -1; + public int clipDepth = -1; } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index d76078c28..9ca219e47 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -101,6 +101,7 @@ import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.filters.BlendComposite; @@ -2207,7 +2208,7 @@ 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, Matrix transformation) { + public static SerializableImage frameToImage(int containerId, int frame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { String key = "frame_" + frame + "_" + containerId + "_" + allTags.get(0).getSwf().hashCode(); SerializableImage image = getFromCache(key); if (image != null) { @@ -2234,7 +2235,7 @@ public final class SWF implements TreeItem { 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); + frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, m, colorTransform); putToCache(key, image); return image; } @@ -2301,14 +2302,10 @@ public final class SWF implements TreeItem { if (instanceName != null) { layer.instanceName = instanceName; } - CXFORM colorTransForm = po.getColorTransform(); + ColorTransform colorTransForm = po.getColorTransform(); if (colorTransForm != null) { layer.colorTransForm = colorTransForm; } - CXFORMWITHALPHA colorTransFormAlpha = po.getColorTransformWithAlpha(); - if (colorTransFormAlpha != null) { - layer.colorTransFormAlpha = colorTransFormAlpha; - } if (po.cacheAsBitmap()) { layer.cacheAsBitmap = true; } @@ -2332,7 +2329,6 @@ public final class SWF implements TreeItem { layer.matrix = po.getMatrix(); layer.instanceName = po.getInstanceName(); layer.colorTransForm = po.getColorTransform(); - layer.colorTransFormAlpha = po.getColorTransformWithAlpha(); layer.cacheAsBitmap = po.cacheAsBitmap(); layer.blendMode = po.getBlendMode(); layer.filters = po.getFilters(); @@ -2373,7 +2369,7 @@ public final class SWF implements TreeItem { return ret; } - public static void framesToImage(int containerId, List ret, int startFrame, int stopFrame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation) { + public static void framesToImage(int containerId, List ret, int startFrame, int stopFrame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { List frameInfos = getFrameInfo(startFrame, stopFrame, allTags, controlTags, totalFrameCount); RECT rect = displayRect; for (FrameInfo fi : frameInfos) { @@ -2389,7 +2385,7 @@ public final class SWF implements TreeItem { 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); + frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, m, colorTransform); ret.add(image); } } @@ -2406,7 +2402,7 @@ public final class SWF implements TreeItem { } - public static void frameToImage(int containerId, int maxDepth, Map layers, Color backgroundColor, Map characters, int frame, List allTags, List controlTags, RECT displayRect, Stack visited, SerializableImage image, Matrix transformation) { + public static void frameToImage(int containerId, int maxDepth, Map layers, Color backgroundColor, Map characters, int frame, List allTags, List controlTags, RECT displayRect, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { float unzoom = (float) SWF.unitDivisor; Graphics2D g = (Graphics2D) image.getGraphics(); @@ -2439,6 +2435,15 @@ public final class SWF implements TreeItem { Matrix mat = new Matrix(layer.matrix); mat = mat.preConcatenate(transformation); + if (colorTransform == null) { + colorTransform = new ColorTransform(); + } + + ColorTransform clrTrans = (ColorTransform) Helper.deepCopy(colorTransform); + if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode + clrTrans = colorTransform.merge(layer.colorTransForm); + } + boolean showPlaceholder = false; if (character instanceof DrawableTag) { DrawableTag drawable = (DrawableTag) character; @@ -2468,29 +2473,32 @@ public final class SWF implements TreeItem { gr.setComposite(AlphaComposite.Src); gr.setColor(new Color(0, 0, 0, 0f)); gr.fillRect(0, 0, img.getWidth(), image.getHeight()); - drawable.toImage(dframe, layer.ratio, allTags, characters, visited, img, m); + drawable.toImage(dframe, layer.ratio, allTags, characters, visited, img, m, clrTrans); } else { // only DefineFont tags - img = drawable.toImage(dframe, layer.ratio, allTags, characters, visited, transformation); + img = drawable.toImage(dframe, layer.ratio, allTags, characters, visited, transformation, clrTrans); } if (layer.filters != null) { for (FILTER filter : layer.filters) { img = filter.apply(img); } } - if (layer.colorTransForm != null) { - img = layer.colorTransForm.apply(img); + if (layer.blendMode > 1) { + if (layer.colorTransForm != null) { + img = layer.colorTransForm.apply(img); + } } - if (layer.colorTransFormAlpha != null) { - img = layer.colorTransFormAlpha.apply(img); - } + drawMatrix.translateX /= unzoom; + drawMatrix.translateY /= unzoom; + AffineTransform trans = drawMatrix.toTransform(); + switch (layer.blendMode) { case 0: case 1: g.setComposite(AlphaComposite.SrcOver); break; - case 2: //TODO:Layer + case 2://Layer g.setComposite(AlphaComposite.SrcOver); break; case 3: @@ -2534,10 +2542,6 @@ public final class SWF implements TreeItem { break; } - drawMatrix.translateX /= unzoom; - drawMatrix.translateY /= unzoom; - AffineTransform trans = drawMatrix.toTransform(); - if (layer.clipDepth > -1) { BufferedImage mask = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); Graphics2D gm = (Graphics2D) mask.getGraphics(); @@ -2582,11 +2586,11 @@ public final class SWF implements TreeItem { g.setTransform(AffineTransform.getScaleInstance(1, 1)); } - public static void frameToImage(int containerId, int frame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, SerializableImage image, Matrix transformation) { + public static void frameToImage(int containerId, int frame, List allTags, List controlTags, RECT displayRect, int totalFrameCount, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { List frameInfos = getFrameInfo(frame, frame, allTags, controlTags, totalFrameCount); if (!frameInfos.isEmpty()) { FrameInfo fi = frameInfos.get(0); - frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, transformation); + frameToImage(containerId, fi.maxDepth, fi.layers, fi.backgroundColor, fi.characters, fi.frame, allTags, controlTags, displayRect, visited, image, transformation, colorTransform); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java index adaf718dc..e157eea49 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.GRADIENT; import com.jpexs.decompiler.flash.types.GRADRECORD; @@ -66,20 +67,21 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter private Stroke lineStroke; private Stroke defaultStroke; private double unitDivisor; + - public static SerializableImage export(SWF swf, SHAPE shape, Color defaultColor) { - BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor); + public static SerializableImage export(SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) { + BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor, colorTransform); exporter.export(); return exporter.getImage(); } - public static void exportTo(SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation) { - BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor); + public static void exportTo(SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor,colorTransform); exporter.exportTo(image, transformation); } - private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor) { - super(shape); + private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) { + super(shape,colorTransform); this.swf = swf; this.defaultColor = defaultColor; } @@ -283,7 +285,7 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter } @Override - public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth) { + public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth, ColorTransform colorTransform) { finalizePath(); matrix.translateX /= unitDivisor; matrix.translateY /= unitDivisor; @@ -302,8 +304,9 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter } } if (image != null) { - SerializableImage img = image.getImage(swf.tags); + SerializableImage img = image.getImage(swf.tags); if (img != null) { + img = colorTransform.apply(img); fillPaint = new TexturePaint(img.getBufferedImage(), new java.awt.Rectangle(img.getWidth(), img.getHeight())); matrix.translateX -= deltaX; matrix.translateY -= deltaY; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java index be21bb739..f02ce2725 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/DefaultSVGShapeExporter.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.SHAPE; @@ -33,8 +34,8 @@ public class DefaultSVGShapeExporter extends ShapeExporterBase implements IShape protected String currentDrawCommand = ""; protected String pathData; - public DefaultSVGShapeExporter(SHAPE shape) { - super(shape); + public DefaultSVGShapeExporter(SHAPE shape,ColorTransform colorTransform) { + super(shape,colorTransform); } @Override @@ -73,7 +74,7 @@ public class DefaultSVGShapeExporter extends ShapeExporterBase implements IShape } @Override - public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth) { + public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth,ColorTransform colorTransform) { finalizePath(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/IShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/IShapeExporter.java index dfd836ad1..843f81dd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/IShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/IShapeExporter.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; @@ -41,7 +42,7 @@ public interface IShapeExporter { public void beginGradientFill(int type, GRADRECORD[] gradientRecords, Matrix matrix, int spreadMethod, int interpolationMethod, float focalPointRatio); - public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth); + public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth, ColorTransform colorTransform); public void endFill(); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java index 99e786526..6eaa8d758 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/SVGShapeExporter.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.GRADIENT; import com.jpexs.decompiler.flash.types.GRADRECORD; @@ -72,8 +73,8 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { private final SWF swf; private double maxLineWidth; - public SVGShapeExporter(SWF swf, SHAPE shape) { - super(shape); + public SVGShapeExporter(SWF swf, SHAPE shape, ColorTransform colorTransform) { + super(shape, colorTransform); this.swf = swf; } @@ -160,7 +161,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { } @Override - public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth) { + public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth, ColorTransform colorTransform) { finalizePath(); ImageTag image = null; for (Tag t : swf.tags) { @@ -175,6 +176,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { if (image != null) { SerializableImage img = image.getImage(swf.tags); if (img != null) { + colorTransform.apply(img); int width = img.getWidth(); int height = img.getHeight(); lastPatternId++; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporterBase.java index d02142527..6bdb6bb5c 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.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; import com.jpexs.decompiler.flash.types.LINESTYLE; @@ -56,9 +57,11 @@ public abstract class ShapeExporterBase implements IShapeExporter { private final ExportRectangle bounds = new ExportRectangle(Double.MAX_VALUE, Double.MAX_VALUE, Double.MIN_VALUE, Double.MIN_VALUE); private boolean edgeMapsCreated; + protected ColorTransform colorTransform; - public ShapeExporterBase(SHAPE shape) { + public ShapeExporterBase(SHAPE shape,ColorTransform colorTransform) { this.shape = shape; + this.colorTransform = colorTransform; _fillStyles = new ArrayList<>(); _lineStyles = new ArrayList<>(); if (shape instanceof SHAPEWITHSTYLE) { @@ -270,7 +273,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { switch (fillStyle.fillStyleType) { case FILLSTYLE.SOLID: // Solid fill - beginFill(fillStyle.color); + beginFill(colorTransform.apply(fillStyle.color)); break; case FILLSTYLE.LINEAR_GRADIENT: case FILLSTYLE.RADIAL_GRADIENT: @@ -279,7 +282,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { matrix = new Matrix(fillStyle.gradientMatrix); beginGradientFill( fillStyle.fillStyleType, - fillStyle.gradient.gradientRecords, + colorTransform.apply(fillStyle.gradient.gradientRecords), matrix, fillStyle.gradient.spreadMode, fillStyle.gradient.interpolationMode, @@ -296,7 +299,8 @@ public abstract class ShapeExporterBase implements IShapeExporter { fillStyle.bitmapId, matrix, (fillStyle.fillStyleType == FILLSTYLE.REPEATING_BITMAP || fillStyle.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP), - (fillStyle.fillStyleType == FILLSTYLE.REPEATING_BITMAP || fillStyle.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) + (fillStyle.fillStyleType == FILLSTYLE.REPEATING_BITMAP || fillStyle.fillStyleType == FILLSTYLE.CLIPPED_BITMAP), + colorTransform ); break; } @@ -368,7 +372,7 @@ public abstract class ShapeExporterBase implements IShapeExporter { } lineStyle( lineStyle.width, - lineStyle.color, + colorTransform.apply(lineStyle.color), pixelHintingFlag, scaleMode, startCapStyle, diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 812568bfc..4e678edd9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.gui.player.FlashDisplay; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.SerializableImage; import java.awt.AlphaComposite; @@ -149,10 +150,10 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); - drawable.toImage(0, 0, swf.tags, characters, new Stack(), image, m); + drawable.toImage(0, 0, swf.tags, characters, new Stack(), image, m,new ColorTransform()); img = image; } else { - img = drawable.toImage(0, 0, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + img = drawable.toImage(0, 0, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform()); } SWF.putToCache(key, img); } @@ -227,11 +228,11 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis g.fillRect(0, 0, image.getWidth(), image.getHeight()); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); - drawable.toImage(nframe, nframe, swf.tags, characters, new Stack(), image, m); + drawable.toImage(nframe, nframe, swf.tags, characters, new Stack(), image, m,new ColorTransform()); img = image; } else { - img = drawable.toImage(nframe, nframe, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + img = drawable.toImage(nframe, nframe, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform()); } SWF.putToCache(key, img); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 2d13a1489..31f13c3fb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -99,6 +99,7 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem; import com.jpexs.decompiler.flash.treenodes.ContainerNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; @@ -2462,7 +2463,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(), Matrix.getScaleInstance(1 / SWF.unitDivisor))); + previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform())); } 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 eb9b4d6bd..785b8cc61 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java @@ -21,6 +21,7 @@ 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.decompiler.flash.types.ColorTransform; import com.jpexs.helpers.SerializableImage; import java.awt.BorderLayout; import java.util.ArrayList; @@ -67,7 +68,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(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); + SWF.framesToImage(0, frameImages, 0, swf.frameCount - 1, swf.tags, swf.tags, swf.displayRect, swf.frameCount, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform()); 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 666e06772..e0a82ea36 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.types.BUTTONCONDACTION; import com.jpexs.decompiler.flash.types.BUTTONRECORD; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.annotations.Reserved; @@ -253,12 +254,12 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { if (visited.contains(buttonId)) { return; } @@ -268,7 +269,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded for (BUTTONRECORD r : this.characters) { if (r.buttonStateUp) { Layer layer = new Layer(); - layer.colorTransFormAlpha = r.colorTransform; + layer.colorTransForm = r.colorTransform; layer.blendMode = r.blendMode; layer.filters = r.filterList; layer.matrix = r.placeMatrix; @@ -282,7 +283,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded visited.pop(); RECT displayRect = getRect(characters, visited); visited.push(buttonId); - SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation); + SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 3152c1970..42575c0f0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.types.BUTTONRECORD; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.annotations.Internal; @@ -274,12 +275,12 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { if (visited.contains(buttonId)) { return; } @@ -289,7 +290,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT for (BUTTONRECORD r : this.characters) { if (r.buttonStateUp) { Layer layer = new Layer(); - layer.colorTransFormAlpha = r.colorTransform; + layer.colorTransForm = r.colorTransform; layer.blendMode = r.blendMode; layer.filters = r.filterList; layer.matrix = r.placeMatrix; @@ -303,7 +304,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT visited.pop(); RECT displayRect = getRect(characters, visited); visited.push(buttonId); - SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation); + SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation,colorTransform); visited.pop(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 0441c2cb6..ce10511d4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.tags.text.ParseException; import com.jpexs.decompiler.flash.tags.text.ParsedSymbol; import com.jpexs.decompiler.flash.tags.text.TextLexer; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; @@ -618,12 +619,12 @@ public class DefineEditTextTag extends TextTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { FontTag font = null; for (Tag tag : tags) { if (tag instanceof FontTag) { @@ -684,7 +685,7 @@ public class DefineEditTextTag extends TextTag implements DrawableTag { tr.textColorA = textColor; } textRecords.add(tr); - staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation); + staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation,colorTransform); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index 569e6e90f..5e5345ed9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY; @@ -315,18 +316,18 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { SHAPEWITHSTYLE shape = getShapeAtRatio(ratio); // shapeNum: 4 // todo: Currently the generated image is not cached, because the cache // key contains the hashCode of the finalRecord object, and it is always // recreated - BitmapExporter.exportTo(swf, shape, null, image, transformation); + BitmapExporter.exportTo(swf, shape, null, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 59bff25de..cd1d32177 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY; @@ -298,18 +299,18 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { SHAPEWITHSTYLE shape = getShapeAtRatio(ratio); // shapeNum: 3 // todo: Currently the generated image is not cached, because the cache // key contains the hashCode of the finalRecord object, and it is always // recreated - BitmapExporter.exportTo(swf, shape, null, image, transformation); + BitmapExporter.exportTo(swf, shape, null, image, transformation, colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java index 24224a963..3a7967c25 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -66,19 +67,19 @@ public class DefineShape2Tag extends CharacterTag implements ShapeTag { @Override public String toSVG() { - SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes()); + SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(),new ColorTransform() /*FIXME?*/); exporter.export(); return exporter.getSVG(); } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - BitmapExporter.exportTo(swf, getShapes(), null, image, transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { + BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index ef90e0453..5b7120857 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -71,19 +72,19 @@ public class DefineShape3Tag extends CharacterTag implements ShapeTag { @Override public String toSVG() { - SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes()); + SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(),new ColorTransform() /*FIXME?*/); exporter.export(); return exporter.getSVG(); } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - BitmapExporter.exportTo(swf, getShapes(), null, image, transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { + BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index f0a226cb6..02dfa1431 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.decompiler.flash.types.annotations.Reserved; @@ -74,19 +75,19 @@ public class DefineShape4Tag extends CharacterTag implements ShapeTag { @Override public String toSVG() { - SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes()); + SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(),new ColorTransform() /*FIXME?*/); exporter.export(); return exporter.getSVG(); } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - BitmapExporter.exportTo(swf, getShapes(), null, image, transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) { + BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index 72859c16d..379c41497 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.exporters.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -99,19 +100,19 @@ public class DefineShapeTag extends CharacterTag implements ShapeTag { @Override public String toSVG() { - SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes()); + SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(),new ColorTransform() /*FIXME?*/); exporter.export(); return exporter.getSVG(); } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - BitmapExporter.exportTo(swf, getShapes(), null, image, transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index bc3f6cb09..b720b53b1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -277,18 +278,18 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { if (visited.contains(spriteId)) { return; } RECT rect = getRect(characters, visited); visited.push(spriteId); - SWF.frameToImage(spriteId, frame, tags, subTags, rect, frameCount, visited, image, transformation); + SWF.frameToImage(spriteId, frame, tags, subTags, rect, frameCount, visited, image, transformation, colorTransform); visited.pop(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index f4b3ac48c..f12316967 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.tags.text.ParseException; import com.jpexs.decompiler.flash.tags.text.ParsedSymbol; import com.jpexs.decompiler.flash.tags.text.TextLexer; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; @@ -491,13 +492,13 @@ public class DefineText2Tag extends TextTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation, colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index dbdfe9fd2..65b4ce02f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.tags.text.ParseException; import com.jpexs.decompiler.flash.tags.text.ParsedSymbol; import com.jpexs.decompiler.flash.tags.text.TextLexer; import com.jpexs.decompiler.flash.types.BasicType; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; @@ -507,13 +508,13 @@ public class DefineTextTag extends TextTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation,ColorTransform colorTransform) { throw new Error("this overload of toImage call is not supported on BoundedTag"); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { - staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation, colorTransform); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 3fbd20439..55261a959 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.annotations.Conditional; @@ -324,12 +325,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO } @Override - public CXFORM getColorTransform() { - return null; - } - - @Override - public CXFORMWITHALPHA getColorTransformWithAlpha() { + public ColorTransform getColorTransform() { if (placeFlagHasColorTransform) { return colorTransform; } else { @@ -337,6 +333,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO } } + @Override public int getBlendMode() { return 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index e5e02ed3e..7222524eb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.annotations.Conditional; @@ -444,12 +445,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO } @Override - public CXFORM getColorTransform() { - return null; - } - - @Override - public CXFORMWITHALPHA getColorTransformWithAlpha() { + public ColorTransform getColorTransform() { if (placeFlagHasColorTransform) { return colorTransform; } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index 2304a7fcc..90bb90633 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.annotations.Conditional; @@ -447,12 +448,7 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO } @Override - public CXFORM getColorTransform() { - return null; - } - - @Override - public CXFORMWITHALPHA getColorTransformWithAlpha() { + public ColorTransform getColorTransform() { if (placeFlagHasColorTransform) { return colorTransform; } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java index 5edeea44a..bc2a5cf51 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.annotations.Optional; @@ -154,15 +155,10 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag } @Override - public CXFORM getColorTransform() { + public ColorTransform getColorTransform() { return colorTransform; } - @Override - public CXFORMWITHALPHA getColorTransformWithAlpha() { - return null; - } - @Override public int getBlendMode() { return 0; 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 fc1d2669d..99991573c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java @@ -19,6 +19,7 @@ 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.decompiler.flash.types.ColorTransform; import com.jpexs.helpers.SerializableImage; import java.util.List; import java.util.Map; @@ -30,9 +31,9 @@ import java.util.Stack; */ public interface DrawableTag { - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation); + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform); - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation); + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform); public Point getImagePos(int frame, Map 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 091f669d6..1856f580c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.TEXTRECORD; @@ -246,12 +247,12 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { - return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black); + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { + return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black,colorTransform); } @Override - public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation) { + public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java index e9556ac3c..f6cb95b7c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.filters.FILTER; @@ -42,9 +43,7 @@ public interface PlaceObjectTypeTag { public void setClassName(String className); - public CXFORM getColorTransform(); - - public CXFORMWITHALPHA getColorTransformWithAlpha(); + public ColorTransform getColorTransform(); public int getBlendMode(); 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 bd5929b04..8584e3ad1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -21,6 +21,7 @@ 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.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; @@ -192,7 +193,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { return att; } - public static void staticTextToImage(SWF swf, Map characters, List textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation) { + public static void staticTextToImage(SWF swf, Map characters, List textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation,ColorTransform colorTransform) { Color textColor = new Color(0, 0, 0); FontTag font = null; int textHeight = 12; @@ -203,9 +204,9 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { for (TEXTRECORD rec : textRecords) { if (rec.styleFlagsHasColor) { if (numText == 2) { - textColor = rec.textColorA.toColor(); + textColor = colorTransform.apply(rec.textColorA.toColor()); } else { - textColor = rec.textColor.toColor(); + textColor = colorTransform.apply(rec.textColor.toColor()); } } if (rec.styleFlagsHasFont) { @@ -231,7 +232,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag { if (entry.glyphIndex != -1) { // shapeNum: 1 SHAPE shape = glyphs.get(entry.glyphIndex); - BitmapExporter.exportTo(swf, shape, textColor, image, mat); + BitmapExporter.exportTo(swf, shape, textColor, image, mat,colorTransform); x += entry.glyphAdvance; } } 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 4b274d827..62ae5f943 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.KERNINGRECORD; import com.jpexs.decompiler.flash.types.LANGCODE; import com.jpexs.decompiler.flash.types.RECT; @@ -115,7 +116,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { } @Override - public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation) { + public SerializableImage toImage(int frame, int ratio, List tags, Map characters, Stack visited, Matrix transformation, ColorTransform colorTransform) { List shapes = new ArrayList<>(); for (int i = 0; i < shapeCache.size(); i++) { shapes.add(SHAPERECORD.resizeSHAPE(shapeCache.get(i), SWF.unitDivisor)); @@ -125,7 +126,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { if (size / cols < 30) { size = cols * 30; } - SerializableImage ret = SHAPERECORD.shapeListToImage(swf, shapes, size, size, Color.black); + SerializableImage ret = SHAPERECORD.shapeListToImage(swf, shapes, size, size, Color.black,colorTransform); return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java index 4c3d39d19..0e0325cf0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.filters.FILTER; @@ -34,8 +35,7 @@ public class DepthState { public int characterId; public MATRIX matrix = null; public String instanceName = null; - public CXFORM colorTransForm = null; - public CXFORMWITHALPHA colorTransFormAlpha = null; + public ColorTransform colorTransForm = null; public boolean cacheAsBitmap = false; public int blendMode = 0; public List filters = new ArrayList<>(); @@ -54,7 +54,6 @@ public class DepthState { matrix = obj.matrix; instanceName = obj.instanceName; colorTransForm = obj.colorTransForm; - colorTransFormAlpha = obj.colorTransFormAlpha; cacheAsBitmap = obj.cacheAsBitmap; blendMode = obj.blendMode; filters = obj.filters; diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java new file mode 100644 index 000000000..1f05f418e --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.timeline; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.tags.DoActionTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; +import com.jpexs.decompiler.flash.tags.base.RemoveTag; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; +import com.jpexs.decompiler.flash.types.CXFORM; +import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.MATRIX; +import com.jpexs.decompiler.flash.types.filters.FILTER; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Timeline { + + public List frames = new ArrayList<>(); + + public Timeline() { + } + + public int getMaxDepth() { + int max_depth = 0; + for (Frame f : frames) { + for (int depth : f.layers.keySet()) { + if (depth > max_depth) { + max_depth = depth; + } + } + } + return max_depth; + } + + public int getFrameCount() { + return frames.size(); + } + + public Timeline(SWF swf) { + Frame frame = new Frame(); + for (Tag t : swf.tags) { + if (t instanceof PlaceObjectTypeTag) { + PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; + int depth = po.getDepth(); + if (!frame.layers.containsKey(depth)) { + frame.layers.put(depth, new DepthState()); + } + DepthState fl = frame.layers.get(depth); + int characterId = po.getCharacterId(); + if (characterId != -1) { + fl.characterId = characterId; + } + if (po.flagMove()) { + MATRIX matrix2 = po.getMatrix(); + if (matrix2 != null) { + fl.matrix = matrix2; + } + String instanceName2 = po.getInstanceName(); + if (instanceName2 != null) { + fl.instanceName = instanceName2; + } + ColorTransform colorTransForm2 = po.getColorTransform(); + if (colorTransForm2 != null) { + fl.colorTransForm = colorTransForm2; + } + + + CLIPACTIONS clipActions2 = po.getClipActions(); + if (clipActions2 != null) { + fl.clipActions = clipActions2; + } + if (po.cacheAsBitmap()) { + fl.cacheAsBitmap = true; + } + int blendMode2 = po.getBlendMode(); + if (blendMode2 > 0) { + fl.blendMode = blendMode2; + } + List filters2 = po.getFilters(); + if (filters2 != null) { + fl.filters = filters2; + } + int ratio2 = po.getRatio(); + if (ratio2 > -1) { + fl.ratio = ratio2; + } + } else { + fl.matrix = po.getMatrix(); + fl.instanceName = po.getInstanceName(); + fl.colorTransForm = po.getColorTransform(); + fl.cacheAsBitmap = po.cacheAsBitmap(); + fl.blendMode = po.getBlendMode(); + fl.filters = po.getFilters(); + fl.ratio = po.getRatio(); + fl.clipActions = po.getClipActions(); + } + fl.key = true; + } + if (t instanceof RemoveTag) { + RemoveTag r = (RemoveTag) t; + int depth = r.getDepth(); + frame.layers.remove(depth); + } + if (t instanceof DoActionTag) { + frame.action = (DoActionTag) t; + } + if (t instanceof ShowFrameTag) { + frames.add(frame); + frame = new Frame(frame); + } + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CXFORM.java b/trunk/src/com/jpexs/decompiler/flash/types/CXFORM.java index 4f920d469..f05e86c28 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CXFORM.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CXFORM.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.types.annotations.Calculated; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.filters.Filtering; import com.jpexs.helpers.SerializableImage; +import java.awt.Color; import java.io.Serializable; /** @@ -28,7 +29,7 @@ import java.io.Serializable; * * @author JPEXS */ -public class CXFORM implements Serializable { +public class CXFORM extends ColorTransform implements Serializable { /** * Has color addition values @@ -72,7 +73,34 @@ public class CXFORM implements Serializable { @SWFType(value = BasicType.SB, countField = "nbits") public int blueAddTerm; - public SerializableImage apply(SerializableImage src) { - return Filtering.colorEffect(src, hasAddTerms ? redAddTerm : 0, hasAddTerms ? greenAddTerm : 0, hasAddTerms ? blueAddTerm : 0, 0, hasMultTerms ? redMultTerm : 255, hasMultTerms ? greenMultTerm : 255, hasMultTerms ? blueMultTerm : 255, 1); + @Override + public int getRedAdd() { + return hasAddTerms?redAddTerm:super.getRedAdd(); } + + @Override + public int getGreenAdd() { + return hasAddTerms?greenAddTerm:super.getGreenAdd(); + } + + @Override + public int getBlueAdd() { + return hasAddTerms?blueAddTerm:super.getBlueAdd(); + } + + @Override + public int getRedMulti() { + return hasMultTerms?redMultTerm:super.getRedMulti(); + } + + @Override + public int getGreenMulti() { + return hasMultTerms?greenMultTerm:super.getGreenMulti(); + } + + @Override + public int getBlueMulti() { + return hasMultTerms?blueMultTerm:super.getBlueMulti(); + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java b/trunk/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java index 27fbe1d8a..500f520ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CXFORMWITHALPHA.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.filters.Filtering; import com.jpexs.helpers.SerializableImage; +import java.awt.Color; import java.io.Serializable; /** @@ -29,7 +30,7 @@ import java.io.Serializable; * * @author JPEXS */ -public class CXFORMWITHALPHA implements Serializable { +public class CXFORMWITHALPHA extends ColorTransform implements Serializable { /** * Has color addition values @@ -92,7 +93,44 @@ public class CXFORMWITHALPHA implements Serializable { @SWFType(value = BasicType.UB, count = 4) public int nbits; - public SerializableImage apply(SerializableImage src) { - return Filtering.colorEffect(src, hasAddTerms ? redAddTerm : 0, hasAddTerms ? greenAddTerm : 0, hasAddTerms ? blueAddTerm : 0, hasAddTerms ? alphaAddTerm : 0, hasMultTerms ? redMultTerm : 255, hasMultTerms ? greenMultTerm : 255, hasMultTerms ? blueMultTerm : 255, hasMultTerms ? alphaMultTerm : 255); + @Override + public int getRedAdd() { + return hasAddTerms?redAddTerm:super.getRedAdd(); } + + @Override + public int getGreenAdd() { + return hasAddTerms?greenAddTerm:super.getGreenAdd(); + } + + @Override + public int getBlueAdd() { + return hasAddTerms?blueAddTerm:super.getBlueAdd(); + } + + @Override + public int getAlphaAdd() { + return hasAddTerms?alphaAddTerm:super.getAlphaAdd(); + } + + @Override + public int getRedMulti() { + return hasMultTerms?redMultTerm:super.getRedMulti(); + } + + @Override + public int getGreenMulti() { + return hasMultTerms?greenMultTerm:super.getGreenMulti(); + } + + @Override + public int getBlueMulti() { + return hasMultTerms?blueMultTerm:super.getBlueMulti(); + } + + @Override + public int getAlphaMulti() { + return hasMultTerms?alphaMultTerm:super.getAlphaMulti(); + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/ColorTransform.java b/trunk/src/com/jpexs/decompiler/flash/types/ColorTransform.java new file mode 100644 index 000000000..938e9a222 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/ColorTransform.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types; + +import com.jpexs.decompiler.flash.types.filters.Filtering; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.SerializableImage; +import java.awt.Color; +import java.awt.image.RescaleOp; +import java.io.Serializable; + +/** + * + * @author JPEXS + */ +public class ColorTransform implements Serializable { + + public RescaleOp toRescaleOp(){ + return new RescaleOp(new float[]{getRedMulti()/255f,getGreenMulti()/255f,getBlueMulti()/255f,getAlphaMulti()/255f}, + new float[]{getRedAdd(),getGreenAdd(),getBlueAdd(),getAlphaAdd()} + , null); + } + + public SerializableImage apply(SerializableImage src) { + return Filtering.colorEffect(src, getRedAdd(), getGreenAdd(), getBlueAdd(), getAlphaAdd(), getRedMulti(), getGreenMulti(), getBlueMulti(), getAlphaMulti()); + } + + public Color apply(Color color) { + return Filtering.colorEffect(color, getRedAdd(), getGreenAdd(), getBlueAdd(), getAlphaAdd(), getRedMulti(), getGreenMulti(), getBlueMulti(), getAlphaMulti()); + } + + public RGB apply(RGB color) { + return new RGBA(Filtering.colorEffect(color.toColor(), getRedAdd(), getGreenAdd(), getBlueAdd(), getAlphaAdd(), getRedMulti(), getGreenMulti(), getBlueMulti(), getAlphaMulti())); + } + + public RGBA apply(RGBA color) { + return new RGBA(Filtering.colorEffect(color.toColor(), getRedAdd(), getGreenAdd(), getBlueAdd(), getAlphaAdd(), getRedMulti(), getGreenMulti(), getBlueMulti(), getAlphaMulti())); + } + + public GRADRECORD[] apply(GRADRECORD[] gradRecords){ + @SuppressWarnings("unchecked") + GRADRECORD[] ret=(GRADRECORD[])Helper.deepCopy(gradRecords); + for(GRADRECORD r:ret){ + r.color = apply(r.color); + } + return ret; + } + + public int getRedAdd() { + return 0; + } + + public int getGreenAdd() { + return 0; + } + + public int getBlueAdd() { + return 0; + } + + public int getAlphaAdd() { + return 0; + } + + public int getRedMulti() { + return 255; + } + + public int getGreenMulti() { + return 255; + } + + public int getBlueMulti() { + return 255; + } + + public int getAlphaMulti() { + return 255; + } + + public ColorTransform merge(final ColorTransform c) { + final ColorTransform t = this; + return new ColorTransform() { + + @Override + public int getRedAdd() { + return (t.getRedAdd() + c.getRedAdd()); + } + + @Override + public int getGreenAdd() { + return (t.getGreenAdd() + c.getGreenAdd()); + } + + @Override + public int getBlueAdd() { + return (t.getBlueAdd() + c.getBlueAdd()); + } + + @Override + public int getAlphaAdd() { + return (t.getAlphaAdd() + c.getAlphaAdd()); + } + + @Override + public int getRedMulti() { + return (int)((float)t.getRedMulti() / 255f * c.getRedMulti()); + } + + @Override + public int getGreenMulti() { + return (int)((float)t.getGreenMulti()/ 255f * c.getGreenMulti()); + } + + @Override + public int getBlueMulti() { + return (int)((float)t.getBlueMulti()/ 255f * c.getBlueMulti()); + } + + @Override + public int getAlphaMulti() { + return (int)((float)t.getAlphaMulti()/ 255f * c.getAlphaMulti()); + } + }; + } + + @Override + public String toString() { + return "[colorTransform redAdd="+getRedAdd()+", greenAdd="+getGreenAdd()+", blueAdd="+getBlueAdd()+", alphaAdd="+getAlphaAdd()+ + ", redMulti="+getRedMulti()+", greenMulti="+getGreenMulti()+", blueMulti="+getBlueMulti()+", alphaMulti="+getAlphaMulti()+"]"; + } + + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/BlendComposite.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/BlendComposite.java index fe966b053..fff03b674 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/BlendComposite.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/BlendComposite.java @@ -162,6 +162,7 @@ public final class BlendComposite implements Composite { int[] result = new int[4]; int[] srcPixel = new int[4]; int[] dstPixel = new int[4]; + int[] retPixel = new int[4]; int[] srcPixels = new int[width]; int[] dstPixels = new int[width]; @@ -182,12 +183,23 @@ public final class BlendComposite implements Composite { dstPixel[3] = (pixel >> 24) & 0xFF; blender.blend(srcPixel, dstPixel, result); - - dstPixels[x] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF) << 24 - | ((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF) << 16 - | ((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF) << 8 - | (int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha) & 0xFF; - } + + retPixel[0] = ((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF); + retPixel[1] = ((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF); + retPixel[2] = (int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha)& 0xFF; + retPixel[3] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF); + + float af=((float)srcPixel[3])/255f; + retPixel[0] = (int)((1f-af)*dstPixel[0]+af*retPixel[0]); + retPixel[1] = (int)((1f-af)*dstPixel[1]+af*retPixel[1]); + retPixel[2] = (int)((1f-af)*dstPixel[2]+af*retPixel[2]); + retPixel[3] = (int)((1f-af)*dstPixel[3]+af*retPixel[3]); + + dstPixels[x] = (retPixel[3] << 24) + | retPixel[0] << 16 + | retPixel[1] << 8 + | retPixel[2]; + } dstOut.setDataElements(0, y, width, 1, dstPixels); } } @@ -246,8 +258,8 @@ public final class BlendComposite implements Composite { public void blend(int[] src, int[] dst, int[] result) { result[0] = Math.min(src[0], dst[0]); result[1] = Math.min(src[1], dst[1]); - result[2] = Math.min(src[2], dst[2]); - result[3] = Math.min(255, src[3] + dst[3] - (src[3] * dst[3]) / 255); + result[2] = Math.min(src[2], dst[2]); + result[3] = Math.min(255, src[3] + dst[3] - (src[3] * dst[3]) / 255); } }; case DIFFERENCE: diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java index 354da381b..9c418c4b9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java @@ -167,7 +167,7 @@ public class Filtering { } } - private static void premultiply(int[] p) { + public static void premultiply(int[] p) { int length = p.length; int offset = 0; length += offset; @@ -185,7 +185,7 @@ public class Filtering { } } - private static void unpremultiply(int[] p) { + public static void unpremultiply(int[] p) { int length = p.length; int offset = 0; length += offset; @@ -455,6 +455,21 @@ public class Filtering { return i; } + public static Color colorEffect(Color color, + int redAddTerm, int greenAddTerm, int blueAddTerm, int alphaAddTerm, + int redMultTerm, int greenMultTerm, int blueMultTerm, int alphaMultTerm) { + int rgb = color.getRGB(); + int a = (rgb >> 24) & 0xff; + int r = (rgb >> 16) & 0xff; + int g = (rgb >> 8) & 0xff; + int b = (rgb) & 0xff; + r = Math.max(0, Math.min(((r * redMultTerm) / 255) + redAddTerm, 255)); + g = Math.max(0, Math.min(((g * greenMultTerm) / 255) + greenAddTerm, 255)); + b = Math.max(0, Math.min(((b * blueMultTerm) / 255) + blueAddTerm, 255)); + a = Math.max(0, Math.min(((a * alphaMultTerm) / 255) + alphaAddTerm, 255)); + return new Color(r,g,b,a); + } + public static SerializableImage colorEffect(SerializableImage src, int redAddTerm, int greenAddTerm, int blueAddTerm, int alphaAddTerm, int redMultTerm, int greenMultTerm, int blueMultTerm, int alphaMultTerm) { 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 e5e163d4d..bbaf74479 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.exporters.BitmapExporter; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.helpers.Helper; @@ -124,7 +125,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali return ret; } - public static SerializableImage shapeListToImage(SWF swf, List shapes, int prevWidth, int prevHeight, Color color) { + public static SerializableImage shapeListToImage(SWF swf, List shapes, int prevWidth, int prevHeight, Color color, ColorTransform colorTransform) { if (shapes.isEmpty()) { SerializableImage image = new SerializableImage(1, 1, BufferedImage.TYPE_INT_RGB); //Make all pixels transparent @@ -176,7 +177,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali } // shapeNum: 1 - SerializableImage img = BitmapExporter.export(swf, shapes.get(pos), color); + SerializableImage img = BitmapExporter.export(swf, shapes.get(pos), color, colorTransform); int w1 = img.getWidth(); int h1 = img.getHeight(); diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index af8c8ab70..3c174d1e1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -63,6 +63,7 @@ import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.CXFORM; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; @@ -793,9 +794,6 @@ public class XFLConverter { if (po.getColorTransform() != null) { usageCount++; } - if (po.getColorTransformWithAlpha() != null) { - usageCount++; - } if (po.cacheAsBitmap()) { usageCount++; } @@ -1030,7 +1028,7 @@ public class XFLConverter { return ret; } - public static String convertSymbolInstance(String name, MATRIX matrix, CXFORM colorTransform, CXFORMWITHALPHA colorTransformAlpha, boolean cacheAsBitmap, int blendMode, List filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap characters, List tags, FLAVersion flaVersion) { + public static String convertSymbolInstance(String name, MATRIX matrix, ColorTransform colorTransform, boolean cacheAsBitmap, int blendMode, List filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap characters, List tags, FLAVersion flaVersion) { String ret = ""; if (matrix == null) { matrix = new MATRIX(); @@ -1090,31 +1088,32 @@ public class XFLConverter { } if (colorTransform != null) { ret += " filters = new ArrayList<>(); @@ -1796,16 +1794,11 @@ public class XFLConverter { if (instanceName2 != null) { instanceName = instanceName2; } - CXFORM colorTransForm2 = po.getColorTransform(); + ColorTransform colorTransForm2 = po.getColorTransform(); if (colorTransForm2 != null) { colorTransForm = colorTransForm2; } - CXFORMWITHALPHA colorTransFormAlpha2 = po.getColorTransformWithAlpha(); - if (colorTransFormAlpha2 != null) { - colorTransFormAlpha = colorTransFormAlpha2; - } - CLIPACTIONS clipActions2 = po.getClipActions(); if (clipActions2 != null) { clipActions = clipActions2; @@ -1829,7 +1822,6 @@ public class XFLConverter { matrix = po.getMatrix(); instanceName = po.getInstanceName(); colorTransForm = po.getColorTransform(); - colorTransFormAlpha = po.getColorTransformWithAlpha(); cacheAsBitmap = po.cacheAsBitmap(); blendMode = po.getBlendMode(); filters = po.getFilters(); @@ -1853,7 +1845,6 @@ public class XFLConverter { matrix = null; instanceName = null; colorTransForm = null; - colorTransFormAlpha = null; cacheAsBitmap = false; blendMode = 0; filters = new ArrayList<>(); @@ -1884,7 +1875,7 @@ public class XFLConverter { } else if (character instanceof DefineVideoStreamTag) { elements += convertVideoInstance(instanceName, matrix, (DefineVideoStreamTag) character, clipActions); } else { - elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags, flaVersion); + elements += convertSymbolInstance(instanceName, matrix, colorTransForm, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags, flaVersion); } } }