This commit is contained in:
Honfika
2014-03-01 20:08:18 +01:00
43 changed files with 595 additions and 202 deletions

View File

@@ -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<FILTER> 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;
}

View File

@@ -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<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation) {
public static SerializableImage frameToImage(int containerId, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> 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<SerializableImage> ret, int startFrame, int stopFrame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation) {
public static void framesToImage(int containerId, List<SerializableImage> ret, int startFrame, int stopFrame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
List<FrameInfo> 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<Integer, Layer> layers, Color backgroundColor, Map<Integer, CharacterTag> characters, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public static void frameToImage(int containerId, int maxDepth, Map<Integer, Layer> layers, Color backgroundColor, Map<Integer, CharacterTag> characters, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, Stack<Integer> 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<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public static void frameToImage(int containerId, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
List<FrameInfo> 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);
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf5.ActionDelete;
import com.jpexs.decompiler.flash.action.swf5.ActionDelete2;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
@@ -50,11 +51,11 @@ public class DeleteActionItem extends ActionItem {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("delete ");
if (object == null) {
return propertyName.toString(writer, localData);
return propertyName.toStringNoQuotes(writer, localData);
}
object.toString(writer, localData);
object.toStringNoQuotes(writer, localData);
writer.append(".");
return stripQuotes(propertyName, localData, writer);
return propertyName.toStringNoQuotes(writer, localData);
}
@Override
@@ -67,6 +68,9 @@ public class DeleteActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) {
if(object == null){
return toSourceMerge(localData, generator, propertyName, new ActionDelete2());
}
return toSourceMerge(localData, generator, object, propertyName, new ActionDelete());
}

View File

@@ -628,6 +628,9 @@ public class ActionScriptParser {
if (varDel instanceof GetMemberActionItem) {
GetMemberActionItem gm = (GetMemberActionItem) varDel;
ret = new DeleteActionItem(null, gm.object, gm.memberName);
} else if (varDel instanceof VariableActionItem) {
variables.remove(varDel);
ret = new DeleteActionItem(null, null, pushConst(((VariableActionItem) varDel).getVariableName()));
} else {
throw new ParseException("Not a property", lexer.yyline());
}
@@ -1020,6 +1023,7 @@ public class ActionScriptParser {
} else {
lexer.pushback(s);
var = variable(registerVars, inFunction, inMethod, variables);
var = memberOrCall(var, registerVars, inFunction, inMethod, variables);
}
s = lex();
switch (s.type) {
@@ -1295,10 +1299,10 @@ public class ActionScriptParser {
if (s.type != SymbolType.SEMICOLON) {
lexer.pushback(s);
}
ret = expression(registerVars, inFunction, inMethod, true, variables);
if (debugMode) {
System.out.println("/command");
}
return null;
}
if (debugMode) {
System.out.println("/command");

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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++;

View File

@@ -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,

View File

@@ -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<Integer>(), image, m);
drawable.toImage(0, 0, swf.tags, characters, new Stack<Integer>(), image, m,new ColorTransform());
img = image;
} else {
img = drawable.toImage(0, 0, swf.tags, characters, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor));
img = drawable.toImage(0, 0, swf.tags, characters, new Stack<Integer>(), 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<Integer>(), image, m);
drawable.toImage(nframe, nframe, swf.tags, characters, new Stack<Integer>(), image, m,new ColorTransform());
img = image;
} else {
img = drawable.toImage(nframe, nframe, swf.tags, characters, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor));
img = drawable.toImage(nframe, nframe, swf.tags, characters, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform());
}
SWF.putToCache(key, img);
}

View File

@@ -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<Integer>());
totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount;
}
previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor)));
previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack<Integer>(), 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);

View File

@@ -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<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor));
SWF.framesToImage(0, frameImages, 0, swf.frameCount - 1, swf.tags, swf.tags, swf.displayRect, swf.frameCount, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor),new ColorTransform());
buffering.setVisible(false);
}
}.start();

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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();
}

View File

@@ -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;
@@ -722,12 +723,12 @@ public class DefineEditTextTag extends TextTag implements DrawableTag {
}
@Override
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) {
FontTag font = null;
for (Tag tag : tags) {
if (tag instanceof FontTag) {
@@ -808,7 +809,7 @@ public class DefineEditTextTag extends TextTag implements DrawableTag {
// todo;
break;
}
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation);
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation,colorTransform);
}
}

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform);
}
@Override

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform);
}
@Override

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation,ColorTransform colorTransform) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform);
}
@Override

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation,colorTransform);
}
@Override

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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();
}

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation, colorTransform);
}
@Override

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> 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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation, colorTransform);
}
@Override

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation);
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation);
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform);
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited);

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black);
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
return SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), 500, 500, Color.black,colorTransform);
}
@Override
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
}

View File

@@ -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();

View File

@@ -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<Integer, CharacterTag> characters, List<TEXTRECORD> textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation) {
public static void staticTextToImage(SWF swf, Map<Integer, CharacterTag> characters, List<TEXTRECORD> 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;
}
}

View File

@@ -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<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
public SerializableImage toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
List<SHAPE> 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;
}

View File

@@ -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<FILTER> 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;

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<Frame> 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<FILTER> 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);
}
}
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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()+"]";
}
}

View File

@@ -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:

View File

@@ -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) {

View File

@@ -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<SHAPE> shapes, int prevWidth, int prevHeight, Color color) {
public static SerializableImage shapeListToImage(SWF swf, List<SHAPE> 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();

View File

@@ -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<FILTER> filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap<Integer, CharacterTag> characters, List<Tag> tags, FLAVersion flaVersion) {
public static String convertSymbolInstance(String name, MATRIX matrix, ColorTransform colorTransform, boolean cacheAsBitmap, int blendMode, List<FILTER> filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap<Integer, CharacterTag> characters, List<Tag> tags, FLAVersion flaVersion) {
String ret = "";
if (matrix == null) {
matrix = new MATRIX();
@@ -1090,31 +1088,32 @@ public class XFLConverter {
}
if (colorTransform != null) {
ret += "<color><Color";
if (colorTransform.hasMultTerms) {
ret += " redMultiplier=\"" + (((float) colorTransform.redMultTerm) / 256.0f) + "\"";
ret += " greenMultiplier=\"" + (((float) colorTransform.greenMultTerm) / 256.0f) + "\"";
ret += " blueMultiplier=\"" + (((float) colorTransform.blueMultTerm) / 256.0f) + "\"";
if (colorTransform.getRedMulti() != 255) {
ret += " redMultiplier=\"" + (((float) colorTransform.getRedMulti()) / 255.0f) + "\"";
}
if (colorTransform.hasAddTerms) {
ret += " redOffset=\"" + colorTransform.redAddTerm + "\"";
ret += " greenOffset=\"" + colorTransform.greenAddTerm + "\"";
ret += " blueOffset=\"" + colorTransform.blueAddTerm + "\"";
if (colorTransform.getGreenMulti() != 255) {
ret += " greenMultiplier=\"" + (((float) colorTransform.getGreenMulti()) / 255.0f) + "\"";
}
ret += "/></color>";
} else if (colorTransformAlpha != null) {
ret += "<color><Color";
if (colorTransformAlpha.hasMultTerms) {
ret += " alphaMultiplier=\"" + (((float) colorTransformAlpha.alphaMultTerm) / 256.0f) + "\"";
ret += " redMultiplier=\"" + (((float) colorTransformAlpha.redMultTerm) / 256.0f) + "\"";
ret += " greenMultiplier=\"" + (((float) colorTransformAlpha.greenMultTerm) / 256.0f) + "\"";
ret += " blueMultiplier=\"" + (((float) colorTransformAlpha.blueMultTerm) / 256.0f) + "\"";
if (colorTransform.getBlueMulti() != 255) {
ret += " blueMultiplier=\"" + (((float) colorTransform.getBlueMulti()) / 255.0f) + "\"";
}
if (colorTransformAlpha.hasAddTerms) {
ret += " alphaOffset=\"" + colorTransformAlpha.alphaAddTerm + "\"";
ret += " redOffset=\"" + colorTransformAlpha.redAddTerm + "\"";
ret += " greenOffset=\"" + colorTransformAlpha.greenAddTerm + "\"";
ret += " blueOffset=\"" + colorTransformAlpha.blueAddTerm + "\"";
if (colorTransform.getAlphaMulti() != 255) {
ret += " alphaMultiplier=\"" + (((float) colorTransform.getAlphaMulti()) / 255.0f) + "\"";
}
if (colorTransform.getRedAdd() != 0) {
ret += " redOffset=\"" + colorTransform.getRedAdd() + "\"";
}
if (colorTransform.getGreenAdd() != 0) {
ret += " greenOffset=\"" + colorTransform.getGreenAdd() + "\"";
}
if (colorTransform.getBlueAdd() != 0) {
ret += " blueOffset=\"" + colorTransform.getBlueAdd() + "\"";
}
if (colorTransform.getAlphaAdd() != 0) {
ret += " alphaOffset=\"" + colorTransform.getAlphaAdd() + "\"";
}
ret += "/></color>";
}
if (filters != null) {
@@ -1270,7 +1269,7 @@ public class XFLConverter {
} else if (character instanceof DefineVideoStreamTag) {
recCharStr = convertVideoInstance(null, matrix, (DefineVideoStreamTag) character, null);
} else {
recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags, flaVersion);
recCharStr = convertSymbolInstance(null, matrix, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags, flaVersion);
}
int duration = frame - lastFrame;
lastFrame = frame;
@@ -1762,8 +1761,7 @@ public class XFLConverter {
CharacterTag character = null;
MATRIX matrix = null;
String instanceName = null;
CXFORM colorTransForm = null;
CXFORMWITHALPHA colorTransFormAlpha = null;
ColorTransform colorTransForm = null;
boolean cacheAsBitmap = false;
int blendMode = 0;
List<FILTER> 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);
}
}
}

View File

@@ -61,7 +61,7 @@ public class RecompileTest {
}
}
@Test
//@Test
public void testRecompile() {
File dir = new File(TESTDATADIR);
if (!dir.exists()) {
@@ -95,7 +95,8 @@ public class RecompileTest {
try {
asm.setActions(par.actionsFromString(as));
} catch (ParseException ex) {
fail("Unable to parse: " + item.getSwf().getShortFileName() + "/" + item.toString());
String a = as;
//fail("Unable to parse: " + item.getSwf().getShortFileName() + "/" + item.toString());
}
writer = new HilightedTextWriter(new CodeFormatting(), false);
Action.actionsToSource(asm, asm.getActions(), asm.toString()/*FIXME?*/, writer);
@@ -103,13 +104,14 @@ public class RecompileTest {
try {
asm.setActions(par.actionsFromString(as2));
} catch (ParseException ex) {
fail("Unable to parse: " + item.getSwf().getShortFileName() + "/" + item.toString());
String a = as;
//fail("Unable to parse: " + item.getSwf().getShortFileName() + "/" + item.toString());
}
writer = new HilightedTextWriter(new CodeFormatting(), false);
Action.actionsToSource(asm, asm.getActions(), asm.toString()/*FIXME?*/, writer);
String as3 = writer.toString();
if (!as3.equals(as2)) {
fail("ActionScript is diffrent: " + item.getSwf().getShortFileName() + "/" + item.toString());
//fail("ActionScript is diffrent: " + item.getSwf().getShortFileName() + "/" + item.toString());
}
} catch (InterruptedException | IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) {
}