#1771 DefineShape4 line filled using single color

This commit is contained in:
Jindra Petřík
2022-10-24 22:35:13 +02:00
parent 3bfcf2976c
commit ec6e689652
40 changed files with 637 additions and 366 deletions

View File

@@ -231,6 +231,7 @@ import com.jpexs.decompiler.flash.types.FOCALGRADIENT;
import com.jpexs.decompiler.flash.types.GLYPHENTRY;
import com.jpexs.decompiler.flash.types.GRADIENT;
import com.jpexs.decompiler.flash.types.GRADRECORD;
import com.jpexs.decompiler.flash.types.ILINESTYLE;
import com.jpexs.decompiler.flash.types.KERNINGRECORD;
import com.jpexs.decompiler.flash.types.LANGCODE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
@@ -2794,9 +2795,9 @@ public class SWFInputStream implements AutoCloseable {
ret.lineStyles[i] = readLINESTYLE(shapeNum, "lineStyle");
}
} else {
ret.lineStyles = new LINESTYLE2[lineStyleCount];
ret.lineStyles2 = new LINESTYLE2[lineStyleCount];
for (int i = 0; i < lineStyleCount; i++) {
ret.lineStyles[i] = readLINESTYLE2(shapeNum, "lineStyle");
ret.lineStyles2[i] = readLINESTYLE2(shapeNum, "lineStyle");
}
}
endDumpLevel();

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.amf.amf3.Amf3OutputStream;
@@ -1348,10 +1349,10 @@ public class SWFOutputStream extends OutputStream {
writeUI8(lineStyleCount);
}
for (int i = 0; i < lineStyleCount; i++) {
for (int i = 0; i < lineStyleCount; i++) {
writeLINESTYLE((LINESTYLE) value.lineStyles[i], shapeNum);
}
} else {
} else {
lineStyleCount = value.lineStyles2.length;
if (lineStyleCount >= 0xff) {
writeUI8(0xff);
writeUI16(lineStyleCount);
@@ -1359,7 +1360,7 @@ public class SWFOutputStream extends OutputStream {
writeUI8(lineStyleCount);
}
for (int i = 0; i < lineStyleCount; i++) {
for (int i = 0; i < lineStyleCount; i++) {
writeLINESTYLE2((LINESTYLE2) value.lineStyles2[i], shapeNum);
}
}
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters;
import com.google.typography.font.sfntly.Font;
@@ -193,7 +194,7 @@ public class FontExporter {
char c = t.glyphToChar(i);
SHAPE s = shapes.get(i);
final List<FPoint[]> contours = new ArrayList<>();
final List<FPoint[]> contours = new ArrayList<>();
PathExporter seb = new PathExporter(1, swf, s, null) {
private double transformX(double x) {
return Math.ceil((double) (x / divider));

View File

@@ -93,41 +93,41 @@ public class MorphShapeExporter {
switch (settings.mode) {
case SVG:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
ExportRectangle rect = new ExportRectangle(mst.getRect());
rect.xMax *= settings.zoom;
rect.yMax *= settings.zoom;
rect.xMin *= settings.zoom;
rect.yMin *= settings.zoom;
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;
ExportRectangle rect = new ExportRectangle(mst.getRect());
rect.xMax *= settings.zoom;
rect.yMax *= settings.zoom;
rect.xMin *= settings.zoom;
rect.yMin *= settings.zoom;
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;
case CANVAS:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin);
int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin);
CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY);
cse.export();
Set<Integer> needed = new HashSet<>();
CharacterTag ct = ((CharacterTag) mst);
needed.add(ct.getCharacterId());
ct.getNeededCharactersDeep(needed);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWF.libraryToHtmlCanvas(ct.getSwf(), needed, baos);
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(mst) + mst.getCharacterId(), mst.getRect())));
}
break;
int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin);
int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin);
CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(mst.getShapeNum(), ((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY);
cse.export();
Set<Integer> needed = new HashSet<>();
CharacterTag ct = ((CharacterTag) mst);
needed.add(ct.getCharacterId());
ct.getNeededCharactersDeep(needed);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWF.libraryToHtmlCanvas(ct.getSwf(), needed, baos);
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(mst) + mst.getCharacterId(), mst.getRect())));
}
break;
case SWF:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
try {
new PreviewExporter().exportSwf(fos, mst, null, 0, false);
} catch (ActionParseException ex) {
Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
}
try {
new PreviewExporter().exportSwf(fos, mst, null, 0, false);
} catch (ActionParseException ex) {
Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
break;
}
}, handler).run();
ret.add(file);

View File

@@ -96,16 +96,16 @@ public class ShapeExporter {
switch (settings.mode) {
case SVG:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
ExportRectangle rect = new ExportRectangle(st.getRect());
rect.xMax *= settings.zoom;
rect.yMax *= settings.zoom;
rect.xMin *= settings.zoom;
rect.yMin *= settings.zoom;
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;
ExportRectangle rect = new ExportRectangle(st.getRect());
rect.xMax *= settings.zoom;
rect.yMax *= settings.zoom;
rect.xMin *= settings.zoom;
rect.yMin *= settings.zoom;
SVGExporter exporter = new SVGExporter(rect, settings.zoom);
st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0);
fos.write(Utf8Helper.getBytes(exporter.getSVG()));
}
break;
case PNG:
case BMP:
RECT rect = st.getRect();
@@ -132,29 +132,29 @@ public class ShapeExporter {
break;
case CANVAS:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
SHAPE shp = st.getShapes();
int deltaX = -shp.getBounds().Xmin;
int deltaY = -shp.getBounds().Ymin;
CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY);
cse.export();
Set<Integer> needed = new HashSet<>();
needed.add(st.getCharacterId());
st.getNeededCharactersDeep(needed);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWF.libraryToHtmlCanvas(st.getSwf(), needed, baos);
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(st) + st.getCharacterId(), st.getRect())));
}
break;
SHAPE shp = st.getShapes();
int deltaX = -shp.getBounds().Xmin;
int deltaY = -shp.getBounds().Ymin;
CanvasShapeExporter cse = new CanvasShapeExporter(st.getShapeNum(), null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY);
cse.export();
Set<Integer> needed = new HashSet<>();
needed.add(st.getCharacterId());
st.getNeededCharactersDeep(needed);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWF.libraryToHtmlCanvas(st.getSwf(), needed, baos);
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(st) + st.getCharacterId(), st.getRect())));
}
break;
case SWF:
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
try {
new PreviewExporter().exportSwf(fos, st, null, 0, false);
} catch (ActionParseException ex) {
Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
}
try {
new PreviewExporter().exportSwf(fos, st, null, 0, false);
} catch (ActionParseException ex) {
Logger.getLogger(MorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
break;
}
}, handler).run();
ret.add(file);

View File

@@ -12,9 +12,11 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.commonshape;
import com.jpexs.decompiler.flash.types.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.RGB;
@@ -51,12 +53,12 @@ public class LineStyle {
public FillStyle fillType;
public LineStyle(LINESTYLE lineStyle) {
width = lineStyle.width;
color = lineStyle.color;
isLineStyle2 = lineStyle instanceof LINESTYLE2;
if (isLineStyle2) {
public LineStyle(ILINESTYLE ilineStyle) {
width = ilineStyle.getWidth();
color = ilineStyle.getColor();
if (ilineStyle.getNum() == 2) {
LINESTYLE2 lineStyle2 = (LINESTYLE2) ilineStyle;
isLineStyle2 = true;
noHScaleFlag = lineStyle2.noHScaleFlag;
noVScaleFlag = lineStyle2.noVScaleFlag;
pixelHintingFlag = lineStyle2.pixelHintingFlag;
@@ -69,4 +71,9 @@ public class LineStyle {
fillType = lineStyle2.fillType == null ? null : new FillStyle(lineStyle2.fillType);
}
}
public LineStyle(LINESTYLE lineStyle) {
isLineStyle2 = false;
}
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.morphshape;
import com.jpexs.decompiler.flash.SWF;
@@ -85,8 +86,8 @@ public class CanvasMorphShapeExporter extends MorphShapeExporterBase {
protected int fillHeight;
public CanvasMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double unitDivisor, int deltaX, int deltaY) {
public CanvasMorphShapeExporter(int morphShapeNum, SWF swf, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double unitDivisor, int deltaX, int deltaY) {
super(morphShapeNum, shape, endShape, colorTransform);
this.deltaX = deltaX;
this.deltaY = deltaY;
this.unitDivisor = unitDivisor;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.morphshape;
import com.jpexs.decompiler.flash.SWF;
@@ -40,8 +41,8 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas
protected double zoom;
public DefaultSVGMorphShapeExporter(SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double zoom) {
public DefaultSVGMorphShapeExporter(int morphShapeNum, SHAPE shape, SHAPE endShape, ColorTransform colorTransform, double zoom) {
super(morphShapeNum, shape, endShape, colorTransform);
this.zoom = zoom;
}

View File

@@ -12,13 +12,15 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.morphshape;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
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.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.RGB;
@@ -49,11 +51,11 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
protected List<FILLSTYLE> _fillStyles;
protected List<ILINESTYLE> _lineStyles;
protected List<FILLSTYLE> _fillStylesEnd;
protected List<ILINESTYLE> _lineStylesEnd;
protected List<Map<Integer, List<IMorphEdge>>> _fillEdgeMaps;
@@ -63,7 +65,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
protected ColorTransform colorTransform;
public MorphShapeExporterBase(int morphShapeNum, SHAPE shape, SHAPE endShape, ColorTransform colorTransform) {
this.shape = shape;
this.shapeEnd = endShape;
this.colorTransform = colorTransform;
@@ -72,14 +74,22 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
if (shape instanceof SHAPEWITHSTYLE) {
SHAPEWITHSTYLE shapeWithStyle = (SHAPEWITHSTYLE) shape;
_fillStyles.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles));
_fillStyles.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles));
if (morphShapeNum == 2) {
_lineStyles.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles2));
} else {
_lineStyles.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles));
}
}
_fillStylesEnd = new ArrayList<>();
_lineStylesEnd = new ArrayList<>();
if (endShape instanceof SHAPEWITHSTYLE) {
SHAPEWITHSTYLE shapeWithStyle = (SHAPEWITHSTYLE) endShape;
_fillStylesEnd.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles));
_fillStylesEnd.addAll(Arrays.asList(shapeWithStyle.fillStyles.fillStyles));
if (morphShapeNum == 2) {
_lineStylesEnd.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles2));
} else {
_lineStylesEnd.addAll(Arrays.asList(shapeWithStyle.lineStyles.lineStyles));
}
}
}
@@ -102,8 +112,8 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
endShape();
}
protected void createEdgeMaps(List<FILLSTYLE> fillStyles, List<LINESTYLE> lineStyles,
protected void createEdgeMaps(List<FILLSTYLE> fillStyles, List<ILINESTYLE> lineStyles,
List<FILLSTYLE> fillStylesEnd, List<ILINESTYLE> lineStylesEnd,
List<Map<Integer, List<IMorphEdge>>> fillEdgeMaps, List<Map<Integer, List<IMorphEdge>>> lineEdgeMaps) {
if (!edgeMapsCreated) {
int xPos = 0;
@@ -383,8 +393,8 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
lineStyleIdx = e.getLineStyleIdx();
posX = Integer.MAX_VALUE;
posY = Integer.MAX_VALUE;
posY = Integer.MAX_VALUE;
LINESTYLE lineStyle = null;
ILINESTYLE lineStyle = null;
ILINESTYLE lineStyleEnd = null;
try {
lineStyle = _lineStyles.get(lineStyleIdx - 1);
lineStyleEnd = _lineStylesEnd.get(lineStyleIdx - 1);
@@ -415,10 +425,10 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
hasFillFlag = lineStyle2.hasFillFlag;
}
lineStyle(
lineStyle(
lineStyle.width,
lineStyleEnd.width,
colorTransform == null ? lineStyle.color : colorTransform.apply(lineStyle.color),
lineStyle.getWidth(),
lineStyleEnd.getWidth(),
colorTransform == null ? lineStyle.getColor() : colorTransform.apply(lineStyle.getColor()),
colorTransform == null ? lineStyleEnd.getColor() : colorTransform.apply(lineStyleEnd.getColor()),
pixelHintingFlag,
scaleMode,
startCapStyle,
@@ -567,7 +577,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
v1.addAll(Arrays.asList(v2));
}
protected void appendLineStyles(List<ILINESTYLE> v1, ILINESTYLE[] v2) {
v1.addAll(Arrays.asList(v2));
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.morphshape;
import com.jpexs.decompiler.flash.SWF;
@@ -51,8 +52,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
private final SVGExporter exporter;
public SVGMorphShapeExporter(SWF swf, SHAPE shape, SHAPE endShape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) {
public SVGMorphShapeExporter(int morphShapeNum, SWF swf, SHAPE shape, SHAPE endShape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) {
super(morphShapeNum, shape, endShape, colorTransform, zoom);
this.swf = swf;
this.id = id;
this.defaultColor = defaultColor;

View File

@@ -154,13 +154,13 @@ public class BitmapExporter extends ShapeExporterBase {
}
}
public static void export(SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) {
BitmapExporter exporter = new BitmapExporter(swf, shape, defaultColor, colorTransform);
public static void export(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, SerializableImage image, Matrix transformation, Matrix strokeTransformation, ColorTransform colorTransform, boolean scaleStrokes) {
BitmapExporter exporter = new BitmapExporter(shapeNum, swf, shape, defaultColor, colorTransform);
exporter.exportTo(image, transformation, strokeTransformation, scaleStrokes);
}
private BitmapExporter(SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) {
super(swf, shape, colorTransform);
private BitmapExporter(int shapeNum, SWF swf, SHAPE shape, Color defaultColor, ColorTransform colorTransform) {
super(shapeNum, swf, shape, colorTransform);
this.swf = swf;
this.defaultColor = defaultColor;
}

View File

@@ -149,8 +149,8 @@ public class CanvasShapeExporter extends ShapeExporterBase {
return shapeData.toString();
}
public CanvasShapeExporter(RGB basicFill, double unitDivisor, SWF swf, SHAPE shape, ColorTransform colorTransform, int deltaX, int deltaY) {
super(swf, shape, colorTransform);
public CanvasShapeExporter(int shapeNum, RGB basicFill, double unitDivisor, SWF swf, SHAPE shape, ColorTransform colorTransform, int deltaX, int deltaY) {
super(shapeNum, swf, shape, colorTransform);
this.swf = swf;
this.unitDivisor = unitDivisor;
this.basicFill = basicFill;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.shape;
import com.jpexs.decompiler.flash.SWF;
@@ -38,8 +39,8 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase {
protected double zoom;
public DefaultSVGShapeExporter(SWF swf, SHAPE shape, ColorTransform colorTransform, double zoom) {
public DefaultSVGShapeExporter(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform, double zoom) {
super(shapeNum, swf, shape, colorTransform);
this.zoom = zoom;
}

View File

@@ -41,19 +41,19 @@ public class PathExporter extends ShapeExporterBase {
private GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
public static List<GeneralPath> export(SWF swf, SHAPE shape) {
return export(swf, shape, new ArrayList<>());
public static List<GeneralPath> export(int shapeNum, SWF swf, SHAPE shape) {
return export(shapeNum, swf, shape, new ArrayList<>());
}
public static List<GeneralPath> export(SWF swf, SHAPE shape, List<GeneralPath> strokes) {
PathExporter exporter = new PathExporter(swf, shape, null);
public static List<GeneralPath> export(int shapeNum, SWF swf, SHAPE shape, List<GeneralPath> strokes) {
PathExporter exporter = new PathExporter(shapeNum, swf, shape, null);
exporter.export();
strokes.addAll(exporter.strokes);
return exporter.paths;
}
protected PathExporter(SWF swf, SHAPE shape, ColorTransform colorTransform) {
super(swf, shape, colorTransform);
protected PathExporter(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform) {
super(shapeNum, swf, shape, colorTransform);
}
@Override

View File

@@ -52,8 +52,8 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
private final SVGExporter exporter;
public SVGShapeExporter(SWF swf, SHAPE shape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) {
super(swf, shape, colorTransform, zoom);
public SVGShapeExporter(int shapeNum, SWF swf, SHAPE shape, int id, SVGExporter exporter, Color defaultColor, ColorTransform colorTransform, double zoom) {
super(shapeNum, swf, shape, colorTransform, zoom);
this.swf = swf;
this.id = id;
this.defaultColor = defaultColor;

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.LineStyle;
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.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.RGB;
@@ -47,7 +48,7 @@ import java.util.Map;
public abstract class ShapeExporterBase implements IShapeExporter {
private static final boolean USE_REVERSE_LOOKUP = true;
protected final SHAPE shape;
private final List<FillStyle> _fillStyles;
@@ -60,7 +61,7 @@ public abstract class ShapeExporterBase implements IShapeExporter {
private final ColorTransform colorTransform;
public ShapeExporterBase(SWF swf, SHAPE shape, ColorTransform colorTransform) {
public ShapeExporterBase(int shapeNum, SWF swf, SHAPE shape, ColorTransform colorTransform) {
this.shape = shape;
this.colorTransform = colorTransform;
@@ -75,8 +76,14 @@ public abstract class ShapeExporterBase implements IShapeExporter {
fillStyles.add(new FillStyle(fillStyle));
}
for (LINESTYLE lineStyle : shapeWithStyle.lineStyles.lineStyles) {
lineStyles.add(new LineStyle(lineStyle));
if (shapeNum <= 3) {
for (LINESTYLE lineStyle : shapeWithStyle.lineStyles.lineStyles) {
lineStyles.add(new LineStyle(lineStyle));
}
} else {
for (LINESTYLE2 lineStyle : shapeWithStyle.lineStyles.lineStyles2) {
lineStyles.add(new LineStyle(lineStyle));
}
}
}
@@ -84,7 +91,7 @@ public abstract class ShapeExporterBase implements IShapeExporter {
List<Map<Integer, List<IEdge>>> fillEdgeMaps = new ArrayList<>();
List<Map<Integer, List<IEdge>>> lineEdgeMaps = new ArrayList<>();
try {
createEdgeMaps(shape, fillStyles, lineStyles, fillEdgeMaps, lineEdgeMaps);
createEdgeMaps(shapeNum, shape, fillStyles, lineStyles, fillEdgeMaps, lineEdgeMaps);
} catch (Throwable t) {
t.printStackTrace();
}
@@ -124,7 +131,7 @@ public abstract class ShapeExporterBase implements IShapeExporter {
endShape();
}
private void createEdgeMaps(SHAPE shape, List<FillStyle> fillStyles, List<LineStyle> lineStyles,
private void createEdgeMaps(int shapeNum, SHAPE shape, List<FillStyle> fillStyles, List<LineStyle> lineStyles,
List<Map<Integer, List<IEdge>>> fillEdgeMaps, List<Map<Integer, List<IEdge>>> lineEdgeMaps) {
int xPos = 0;
int yPos = 0;
@@ -149,7 +156,11 @@ public abstract class ShapeExporterBase implements IShapeExporter {
fillStyleIdxOffset = fillStyles.size();
lineStyleIdxOffset = lineStyles.size();
appendFillStyles(fillStyles, styleChangeRecord.fillStyles.fillStyles);
appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles);
if (shapeNum <= 3) {
appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles);
} else {
appendLineStyles(lineStyles, styleChangeRecord.lineStyles.lineStyles2);
}
}
// Check if all styles are reset to 0.
// This (probably) means that a new group starts with the next record
@@ -374,9 +385,13 @@ public abstract class ShapeExporterBase implements IShapeExporter {
miterLimitFactor = lineStyle.miterLimitFactor;
hasFillFlag = lineStyle.hasFillFlag;
}
RGB lineColor = lineStyle.color;
if (hasFillFlag && lineStyle.fillType.fillStyleType == FILLSTYLE.SOLID) {
lineColor = lineStyle.fillType.color;
}
lineStyle(
lineStyle.width,
colorTransform == null ? lineStyle.color : colorTransform.apply(lineStyle.color),
colorTransform == null ? lineColor : colorTransform.apply(lineColor),
pixelHintingFlag,
scaleMode,
startCapStyle,
@@ -613,6 +628,12 @@ public abstract class ShapeExporterBase implements IShapeExporter {
}
}
private void appendLineStyles(List<LineStyle> v1, LINESTYLE2[] v2) {
for (LINESTYLE2 s : v2) {
v1.add(new LineStyle(s));
}
}
private void appendEdges(List<IEdge> v1, List<IEdge> v2) {
for (int i = 0; i < v2.size(); i++) {
//System.err.println("appending " + v2.get(i));

View File

@@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
import com.jpexs.decompiler.flash.types.FOCALGRADIENT;
import com.jpexs.decompiler.flash.types.GRADIENT;
import com.jpexs.decompiler.flash.types.GRADRECORD;
import com.jpexs.decompiler.flash.types.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.LINESTYLEARRAY;
@@ -329,6 +330,7 @@ public class SvgImporter {
showWarning(tagName + "tagNotSupported", "The SVG tag '" + tagName + "' is not supported.");
}
}
private void processSvgObject(Map<String, Element> idMap, int shapeNum, SHAPEWITHSTYLE shapes, Element element, Matrix transform, SvgStyle style) {
for (int i = 0; i < element.getChildNodes().getLength(); i++) {
Node childNode = element.getChildNodes().item(i);
@@ -360,7 +362,7 @@ public class SvgImporter {
newRecords.add(scrStyle);
LINESTYLE lineStyleObj = scrStyle.lineStyles.lineStyles.length < 1 ? null : scrStyle.lineStyles.lineStyles[0];
ILINESTYLE lineStyleObj = scrStyle.lineStyles.lineStyles.length < 1 ? null : scrStyle.lineStyles.lineStyles[0];
LINESTYLE2 lineStyle2Obj = null;
if (lineStyleObj instanceof LINESTYLE2) {
lineStyle2Obj = (LINESTYLE2) lineStyleObj;
@@ -1148,7 +1150,7 @@ public class SvgImporter {
st = (DefineShape4Tag) (new SvgImporter().importSvg(st, svgDataS, false));
swf.addTag(st);
SerializableImage si = new SerializableImage(480, 360, BufferedImage.TYPE_4BYTE_ABGR);
BitmapExporter.export(swf, st.shapes, Color.yellow, si, new Matrix(), new Matrix(), null, true);
BitmapExporter.export(st.getShapeNum(), swf, st.shapes, Color.yellow, si, new Matrix(), new Matrix(), null, true);
List<Tag> li = new ArrayList<>();
li.add(st);
ImageIO.write(si.getBufferedImage(), "PNG", new File(name + ".imported.png"));
@@ -1583,8 +1585,8 @@ public class SvgImporter {
}
SvgFill strokeFill = style.getStrokeFillWithOpacity();
if (strokeFill != null) {
if (scr.lineStyles.lineStyles.length > 0 && scr.lineStyles.lineStyles[0] instanceof LINESTYLE2) {
applyFillGradients(strokeFill, ((LINESTYLE2) scr.lineStyles.lineStyles[0]).fillType, bounds, scr, transform, shapeNum, style);
if (shapeNum == 4 && scr.lineStyles.lineStyles2.length > 0 && scr.lineStyles.lineStyles2[0] instanceof LINESTYLE2) {
applyFillGradients(strokeFill, ((LINESTYLE2) scr.lineStyles.lineStyles2[0]).fillType, bounds, scr, transform, shapeNum, style);
}
}
}
@@ -1619,10 +1621,9 @@ public class SvgImporter {
if (strokeFill != null && strokeFill != SvgTransparentFill.INSTANCE) {
Color lineColor = strokeFill.toColor();
scr.lineStyles.lineStyles = new LINESTYLE[1];
LINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2();
lineStyle.color = getRGB(shapeNum, lineColor);
lineStyle.width = (int) Math.round(style.getStrokeWidth() * SWF.unitDivisor);
ILINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2();
lineStyle.setColor(getRGB(shapeNum, lineColor));
lineStyle.setWidth((int) Math.round(style.getStrokeWidth() * SWF.unitDivisor));
SvgLineCap lineCap = style.getStrokeLineCap();
SvgLineJoin lineJoin = style.getStrokeLineJoin();
if (lineStyle instanceof LINESTYLE2) {
@@ -1643,6 +1644,8 @@ public class SvgImporter {
: lineJoin == SvgLineJoin.BEVEL ? LINESTYLE2.BEVEL_JOIN : 0;
lineStyle2.joinStyle = swfJoin;
lineStyle2.miterLimitFactor = (float) style.getStrokeMiterLimit();
scr.lineStyles.lineStyles2 = new LINESTYLE2[1];
scr.lineStyles.lineStyles2[0] = lineStyle2;
} else {
if (lineCap != SvgLineCap.ROUND) {
showWarning("lineCapNotSupported", "LineCap style not supported in shape " + shapeNum);
@@ -1650,12 +1653,14 @@ public class SvgImporter {
if (lineJoin != SvgLineJoin.ROUND) {
showWarning("lineJoinNotSupported", "LineJoin style not supported in shape " + shapeNum);
}
scr.lineStyles.lineStyles = new LINESTYLE[1];
scr.lineStyles.lineStyles[0] = (LINESTYLE) lineStyle;
}
scr.lineStyles.lineStyles[0] = lineStyle;
scr.lineStyle = 1;
} else {
scr.lineStyles.lineStyles = new LINESTYLE[0];
scr.lineStyles.lineStyles2 = new LINESTYLE2[0];
scr.lineStyle = 0;
}

View File

@@ -434,7 +434,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
@Override
public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) {
SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), image, frame, Color.black, colorTransform);
SHAPERECORD.shapeListToImage(1, swf, getGlyphShapeTable(), image, frame, Color.black, colorTransform);
}
@Override
@@ -451,7 +451,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
String cs = "" + c;
cs = cs.replace("\\", "\\\\").replace("\"", "\\\"");
result.append("\t\tcase \"").append(cs).append("\":\r\n");
CanvasShapeExporter exporter = new CanvasShapeExporter(null, unitDivisor, swf, shapes.get(i), null, 0, 0);
CanvasShapeExporter exporter = new CanvasShapeExporter(1, null, unitDivisor, swf, shapes.get(i), null, 0, 0);
exporter.export();
result.append("\t\t").append(exporter.getShapeData().replaceAll("\r\n", "\r\n\t\t"));
result.append("\tbreak;\r\n");

View File

@@ -227,23 +227,23 @@ public abstract class ImageTag extends DrawableTag {
@Override
public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) {
return transformation.toTransform().createTransformedShape(getShape().getOutline(swf, stroked));
return transformation.toTransform().createTransformedShape(getShape().getOutline(1, swf, stroked));
}
@Override
public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) {
BitmapExporter.export(swf, getShape(), null, image, transformation, strokeTransformation, colorTransform, true);
BitmapExporter.export(1, swf, getShape(), null, image, transformation, strokeTransformation, colorTransform, true);
}
@Override
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShape(), getCharacterId(), exporter, null, colorTransform, 1);
SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, getShape(), getCharacterId(), exporter, null, colorTransform, 1);
shapeExporter.export();
}
@Override
public void toHtmlCanvas(StringBuilder result, double unitDivisor) {
CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, getShape(), null, 0, 0);
CanvasShapeExporter cse = new CanvasShapeExporter(1, null, unitDivisor, swf, getShape(), null, 0, 0);
cse.export();
result.append(cse.getShapeData());
}

View File

@@ -320,7 +320,7 @@ public abstract class MorphShapeTag extends DrawableTag {
// 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.export(swf, shape, null, image, transformation, strokeTransformation, colorTransform, scaleStrokes);
BitmapExporter.export(getShapeNum() == 2 ? 4 : 1, swf, shape, null, image, transformation, strokeTransformation, colorTransform, scaleStrokes);
}
@Override
@@ -328,11 +328,11 @@ public abstract class MorphShapeTag extends DrawableTag {
if (ratio == -2) {
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(swf, beginShapes, endShapes, getCharacterId(), exporter, null, colorTransform, 1);
SVGMorphShapeExporter shapeExporter = new SVGMorphShapeExporter(getShapeNum(), swf, beginShapes, endShapes, getCharacterId(), exporter, null, colorTransform, 1);
shapeExporter.export();
} else {
SHAPEWITHSTYLE shapes = getShapeAtRatio(ratio);
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shapes, getCharacterId(), exporter, null, colorTransform, 1);
SVGShapeExporter shapeExporter = new SVGShapeExporter(getShapeNum() == 2 ? 4 : 1, swf, shapes, getCharacterId(), exporter, null, colorTransform, 1);
shapeExporter.export();
}
}
@@ -350,12 +350,12 @@ public abstract class MorphShapeTag extends DrawableTag {
@Override
public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) {
return transformation.toTransform().createTransformedShape(getShapeAtRatio(ratio).getOutline(swf, stroked));
return transformation.toTransform().createTransformedShape(getShapeAtRatio(ratio).getOutline(getShapeNum() == 2 ? 4 : 1, swf, stroked));
}
@Override
public void toHtmlCanvas(StringBuilder result, double unitDivisor) {
CanvasMorphShapeExporter cmse = new CanvasMorphShapeExporter(swf, getShapeAtRatio(0), getShapeAtRatio(MAX_RATIO), null, unitDivisor, 0, 0);
CanvasMorphShapeExporter cmse = new CanvasMorphShapeExporter(getShapeNum(), swf, getShapeAtRatio(0), getShapeAtRatio(MAX_RATIO), null, unitDivisor, 0, 0);
cmse.export();
result.append(cmse.getShapeData());
}

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
import com.jpexs.decompiler.flash.helpers.LazyObject;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
@@ -131,20 +132,19 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject {
@Override
public RECT getRectWithStrokes() {
int maxWidth = 0;
for (LINESTYLE ls : getShapes().lineStyles.lineStyles) {
if (ls.width > maxWidth) {
maxWidth = ls.width;
for (ILINESTYLE ls : getShapes().lineStyles.lineStyles) {
if (ls.getWidth() > maxWidth) {
maxWidth = ls.getWidth();
}
}
for (SHAPERECORD sr : getShapes().shapeRecords) {
if (sr instanceof StyleChangeRecord) {
StyleChangeRecord scr = (StyleChangeRecord) sr;
if (scr.stateNewStyles) {
for (LINESTYLE ls : scr.lineStyles.lineStyles) {
if (ls.width > maxWidth) {
maxWidth = ls.width;
for (ILINESTYLE ls : scr.lineStyles.lineStyles) {
if (ls.getWidth() > maxWidth) {
maxWidth = ls.getWidth();
}
}
}
@@ -160,7 +160,6 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject {
return r;
}
@Override
public int getUsedParameters() {
return 0;
@@ -168,14 +167,14 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject {
@Override
public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation, boolean stroked) {
return transformation.toTransform().createTransformedShape(getShapes().getOutline(swf, stroked));
return transformation.toTransform().createTransformedShape(getShapes().getOutline(getShapeNum(), swf, stroked));
}
@Override
public void toImage(int frame, int time, int ratio, RenderContext renderContext, SerializableImage image, SerializableImage fullImage, boolean isClip, Matrix transformation, Matrix strokeTransformation, Matrix absoluteTransformation, Matrix fullTransformation, ColorTransform colorTransform, double unzoom, boolean sameImage, ExportRectangle viewRect, boolean scaleStrokes, int drawMode) {
BitmapExporter.export(swf, getShapes(), null, image, transformation, strokeTransformation, colorTransform, scaleStrokes);
BitmapExporter.export(getShapeNum(), swf, getShapes(), null, image, transformation, strokeTransformation, colorTransform, scaleStrokes);
if (Configuration._debugMode.get()) { // show control points
List<GeneralPath> paths = PathExporter.export(swf, getShapes());
List<GeneralPath> paths = PathExporter.export(getShapeNum(), swf, getShapes());
double[] coords = new double[6];
AffineTransform at = transformation.toTransform();
at.preConcatenate(AffineTransform.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor));
@@ -217,13 +216,13 @@ public abstract class ShapeTag extends DrawableTag implements LazyObject {
@Override
public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level) throws IOException {
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, getShapes(), getCharacterId(), exporter, null, colorTransform, 1);
SVGShapeExporter shapeExporter = new SVGShapeExporter(getShapeNum(), swf, getShapes(), getCharacterId(), exporter, null, colorTransform, 1);
shapeExporter.export();
}
@Override
public void toHtmlCanvas(StringBuilder result, double unitDivisor) {
CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, getShapes(), null, 0, 0);
CanvasShapeExporter cse = new CanvasShapeExporter(getShapeNum(), null, unitDivisor, swf, getShapes(), null, 0, 0);
cse.export();
result.append(cse.getShapeData());
}

View File

@@ -422,7 +422,7 @@ public abstract class TextTag extends DrawableTag {
Graphics2D g = (Graphics2D) image.getGraphics();
Matrix mat = transformation.clone();
mat = mat.concatenate(new Matrix(textMatrix));
BitmapExporter.export(swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, mat, colorTransform, true);
BitmapExporter.export(1, swf, getBorderShape(borderColor, fillColor, rect), null, image, mat, mat, colorTransform, true);
}
public static void drawBorderHtmlCanvas(SWF swf, StringBuilder result, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double unitDivisor) {
@@ -430,7 +430,7 @@ public abstract class TextTag extends DrawableTag {
result.append("\tctx.save();\r\n");
result.append("\tctx.transform(").append(mat.scaleX).append(",").append(mat.rotateSkew0).append(",").append(mat.rotateSkew1).append(",").append(mat.scaleY).append(",").append(mat.translateX).append(",").append(mat.translateY).append(");\r\n");
SHAPE shape = getBorderShape(borderColor, fillColor, rect);
CanvasShapeExporter cse = new CanvasShapeExporter(null, unitDivisor, swf, shape, colorTransform, 0, 0);
CanvasShapeExporter cse = new CanvasShapeExporter(1, null, unitDivisor, swf, shape, colorTransform, 0, 0);
cse.export();
result.append(cse.getShapeData());
result.append("\tctx.restore();\r\n");
@@ -439,7 +439,7 @@ public abstract class TextTag extends DrawableTag {
public static void drawBorderSVG(SWF swf, SVGExporter exporter, RGB borderColor, RGB fillColor, RECT rect, MATRIX textMatrix, ColorTransform colorTransform, double zoom) {
exporter.createSubGroup(new Matrix(textMatrix), null);
SHAPE shape = getBorderShape(borderColor, fillColor, rect);
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, 0, exporter, null, colorTransform, zoom);
SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, shape, 0, exporter, null, colorTransform, zoom);
shapeExporter.export();
exporter.endGroup();
}
@@ -512,7 +512,7 @@ public abstract class TextTag extends DrawableTag {
}
if (shape != null) {
BitmapExporter.export(swf, shape, textColor2, image, mat, mat, colorTransform, true);
BitmapExporter.export(1, swf, shape, textColor2, image, mat, mat, colorTransform, true);
if (SHAPERECORD.DRAW_BOUNDING_BOX) {
RGB borderColor = new RGBA(Color.black);
RGB fillColor = new RGBA(new Color(255, 255, 255, 0));
@@ -756,7 +756,7 @@ public abstract class TextTag extends DrawableTag {
if (charId == null) {
charId = exporter.getUniqueId(Helper.getValidHtmlId("font_" + font.getFontNameIntag() + "_" + ch));
exporter.createDefGroup(null, charId);
SVGShapeExporter shapeExporter = new SVGShapeExporter(swf, shape, 0, exporter, null, colorTransform, zoom);
SVGShapeExporter shapeExporter = new SVGShapeExporter(1, swf, shape, 0, exporter, null, colorTransform, zoom);
shapeExporter.export();
if (!exporter.endGroup()) {
charId = "";

View File

@@ -0,0 +1,23 @@
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.helpers.ConcreteClasses;
import java.io.Serializable;
/**
*
* @author JPEXS
*/
@ConcreteClasses({LINESTYLE.class, LINESTYLE2.class})
public interface ILINESTYLE extends NeedsCharacters, Serializable {
public int getNum();
public RGB getColor();
public int getWidth();
public void setColor(RGB color);
public void setWidth(int width);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
@@ -27,7 +28,7 @@ import java.util.Set;
*
* @author JPEXS
*/
*/
public class LINESTYLE implements NeedsCharacters, Serializable, ILINESTYLE {
@SWFType(BasicType.UI16)
public int width;
@@ -48,4 +49,29 @@ public class LINESTYLE implements NeedsCharacters, Serializable {
public boolean removeCharacter(int characterId) {
return false;
}
@Override
public int getNum() {
return 1;
}
@Override
public RGB getColor() {
return color;
}
@Override
public int getWidth() {
return width;
}
@Override
public void setColor(RGB color) {
this.color = color;
}
@Override
public void setWidth(int width) {
this.width = width;
}
}

View File

@@ -12,9 +12,11 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
@@ -26,7 +28,10 @@ import java.util.Set;
*
* @author JPEXS
*/
*/
public class LINESTYLE2 implements NeedsCharacters, Serializable, ILINESTYLE {
@SWFType(BasicType.UI16)
public int width;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = ROUND_CAP, text = "Round cap")
@@ -76,6 +81,10 @@ public class LINESTYLE2 extends LINESTYLE implements Serializable {
@Conditional(value = "joinStyle", options = {MITER_JOIN})
public float miterLimitFactor;
@Conditional(value = "!hasFillFlag")
public RGBA color;
@Conditional(value = "hasFillFlag")
public FILLSTYLE fillType;
@Override
@@ -100,4 +109,36 @@ public class LINESTYLE2 extends LINESTYLE implements Serializable {
}
return false;
}
@Override
public int getNum() {
return 2;
}
@Override
public RGB getColor() {
if (hasFillFlag) {
return null;
}
return color;
}
@Override
public int getWidth() {
return width;
}
@Override
public void setColor(RGB color) {
if (color instanceof RGBA) {
this.color = (RGBA) color;
}
this.color = new RGBA(color.toColor());
hasFillFlag = false;
}
@Override
public void setWidth(int width) {
this.width = width;
}
}

View File

@@ -12,10 +12,16 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
import com.jpexs.decompiler.flash.tags.DefineShape4Tag;
import com.jpexs.decompiler.flash.tags.DefineShapeTag;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import java.io.Serializable;
import java.util.Set;
@@ -27,11 +33,16 @@ import java.util.Set;
public class LINESTYLEARRAY implements NeedsCharacters, Serializable {
@SWFArray(value = "lineStyle")
@Conditional(tags = {DefineShapeTag.ID, DefineShape2Tag.ID, DefineShape3Tag.ID})
public LINESTYLE[] lineStyles = new LINESTYLE[0];
@SWFArray(value = "lineStyle")
@Conditional(tags = {DefineShape4Tag.ID})
public LINESTYLE2[] lineStyles2 = new LINESTYLE2[0];
@Override
public void getNeededCharacters(Set<Integer> needed) {
public void getNeededCharacters(Set<Integer> needed) {
for (ILINESTYLE ls : lineStyles) {
ls.getNeededCharacters(needed);
}
}
@@ -39,7 +50,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable {
@Override
public boolean replaceCharacter(int oldCharacterId, int newCharacterId) {
boolean modified = false;
boolean modified = false;
for (ILINESTYLE ls : lineStyles) {
modified |= ls.replaceCharacter(oldCharacterId, newCharacterId);
}
return modified;
@@ -48,7 +59,7 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable {
@Override
public boolean removeCharacter(int characterId) {
boolean modified = false;
boolean modified = false;
for (ILINESTYLE ls : lineStyles) {
modified |= ls.removeCharacter(characterId);
}
return modified;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import java.io.Serializable;
@@ -36,9 +37,9 @@ public class MORPHLINESTYLEARRAY implements Serializable {
}
}
if (shapeNum == 2) {
if (shapeNum == 2) {
ret.lineStyles2 = new LINESTYLE2[lineStyles2.length];
for (int m = 0; m < lineStyles2.length; m++) {
for (int m = 0; m < lineStyles2.length; m++) {
ret.lineStyles2[m] = lineStyles2[m].getLineStyle2At(ratio);
}
}
return ret;
@@ -53,9 +54,9 @@ public class MORPHLINESTYLEARRAY implements Serializable {
}
}
if (shapeNum == 2) {
if (shapeNum == 2) {
ret.lineStyles2 = new LINESTYLE2[lineStyles2.length];
for (int m = 0; m < lineStyles2.length; m++) {
for (int m = 0; m < lineStyles2.length; m++) {
ret.lineStyles2[m] = lineStyles2[m].getStartLineStyle2();
}
}
return ret;
@@ -70,9 +71,9 @@ public class MORPHLINESTYLEARRAY implements Serializable {
}
}
if (shapeNum == 2) {
if (shapeNum == 2) {
ret.lineStyles2 = new LINESTYLE2[lineStyles2.length];
for (int m = 0; m < lineStyles2.length; m++) {
for (int m = 0; m < lineStyles2.length; m++) {
ret.lineStyles2[m] = lineStyles2[m].getEndLineStyle2();
}
}
return ret;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.SWF;
@@ -76,13 +77,13 @@ public class SHAPE implements NeedsCharacters, Serializable {
return SHAPERECORD.getBounds(shapeRecords);
}
public Shape getOutline(int shapeNum, SWF swf, boolean stroked) {
if (cachedOutline != null) {
return cachedOutline;
}
List<GeneralPath> strokes = new ArrayList<>();
List<GeneralPath> strokes = new ArrayList<>();
List<GeneralPath> paths = PathExporter.export(shapeNum, swf, this, strokes);
Area area = new Area();
for (GeneralPath path : paths) {

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
@@ -91,7 +92,7 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab
if (shapeNum <= 3) {
ret.lineStyles.lineStyles = new LINESTYLE[0];
} else {
} else {
ret.lineStyles.lineStyles2 = new LINESTYLE2[0];
}
return ret;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types.annotations.parser;
import com.jpexs.decompiler.flash.types.annotations.Conditional;

View File

@@ -138,7 +138,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
return ret;
}
public static void shapeListToImage(SWF swf, List<SHAPE> shapes, SerializableImage image, int frame, Color color, ColorTransform colorTransform) {
public static void shapeListToImage(int shapeNum, SWF swf, List<SHAPE> shapes, SerializableImage image, int frame, Color color, ColorTransform colorTransform) {
if (shapes.isEmpty()) {
return;
}
@@ -219,7 +219,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
Matrix transformation = Matrix.getTranslateInstance(px, py);
transformation.scale(ratio);
BitmapExporter.export(swf, shape, color, image, transformation, transformation, colorTransform, true);
BitmapExporter.export(shapeNum, swf, shape, color, image, transformation, transformation, colorTransform, true);
// draw bounding boxes
if (DRAW_BOUNDING_BOX) {

View File

@@ -102,6 +102,7 @@ import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
import com.jpexs.decompiler.flash.types.FOCALGRADIENT;
import com.jpexs.decompiler.flash.types.GRADIENT;
import com.jpexs.decompiler.flash.types.GRADRECORD;
import com.jpexs.decompiler.flash.types.ILINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.LINESTYLEARRAY;
@@ -253,7 +254,7 @@ public class XFLConverter {
}
}
private static String getScaleMode(LINESTYLE lineStyle) {
private static String getScaleMode(ILINESTYLE lineStyle) {
if (lineStyle instanceof LINESTYLE2) {
LINESTYLE2 ls2 = (LINESTYLE2) lineStyle;
if (ls2.noHScaleFlag && ls2.noVScaleFlag) {
@@ -270,16 +271,16 @@ public class XFLConverter {
return "normal";
}
private static void convertLineStyle(LINESTYLE ls, int shapeNum, XFLXmlWriter writer) throws XMLStreamException {
private static void convertLineStyle(ILINESTYLE ls, int shapeNum, XFLXmlWriter writer) throws XMLStreamException {
writer.writeStartElement("SolidStroke", new String[]{
"scaleMode", getScaleMode(ls),
"weight", Double.toString(((float) ls.width) / SWF.unitDivisor),});
"weight", Double.toString(((float) ls.getWidth()) / SWF.unitDivisor),});
writer.writeStartElement("fill");
if (!(ls instanceof LINESTYLE2) || !((LINESTYLE2) ls).hasFillFlag) {
writer.writeStartElement("SolidColor", new String[]{"color", ls.color.toHexRGB()});
writer.writeStartElement("SolidColor", new String[]{"color", ls.getColor().toHexRGB()});
if (shapeNum >= 3) {
writer.writeAttribute("alpha", ((RGBA) ls.color).getAlphaFloat());
writer.writeAttribute("alpha", ((RGBA) ls.getColor()).getAlphaFloat());
}
writer.writeEndElement();
@@ -763,10 +764,10 @@ public class XFLConverter {
strokesStr.writeEndElement();
lineStyleCount++;
}
} else if (lineStyles.lineStyles != null) {
for (int l = 0; l < lineStyles.lineStyles.length; l++) {
} else if (lineStyles.lineStyles2 != null) {
for (int l = 0; l < lineStyles.lineStyles2.length; l++) {
strokesStr.writeStartElement("StrokeStyle", new String[]{"index", Integer.toString(lineStyleCount + 1)});
convertLineStyle(characters, (LINESTYLE2) lineStyles.lineStyles[l], shapeNum, strokesStr);
convertLineStyle(characters, (LINESTYLE2) lineStyles.lineStyles2[l], shapeNum, strokesStr);
strokesStr.writeEndElement();
lineStyleCount++;
}
@@ -815,8 +816,8 @@ public class XFLConverter {
if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) {
if (shapeNum == 4) {
if (strokeStyleOrig > 0) {
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color;
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor();
if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) {
empty = true;
}
@@ -871,9 +872,9 @@ public class XFLConverter {
lineStyleCount++;
}
} else {
for (int l = 0; l < scr.lineStyles.lineStyles.length; l++) {
for (int l = 0; l < scr.lineStyles.lineStyles2.length; l++) {
strokesNewStr.writeStartElement("StrokeStyle", new String[]{"index", Integer.toString(lineStyleCount + 1)});
convertLineStyle(characters, (LINESTYLE2) scr.lineStyles.lineStyles[l], shapeNum, strokesNewStr);
convertLineStyle(characters, (LINESTYLE2) scr.lineStyles.lineStyles2[l], shapeNum, strokesNewStr);
strokesNewStr.writeEndElement();
lineStyleCount++;
}
@@ -914,8 +915,8 @@ public class XFLConverter {
if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) {
if (shapeNum == 4) {
if (strokeStyleOrig > 0) {
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color;
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor();
if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) {
empty = true;
}
@@ -958,8 +959,8 @@ public class XFLConverter {
if ((fillStyle0 <= 0) && (fillStyle1 <= 0) && (strokeStyle > 0) && morphshape) {
if (shapeNum == 4) {
if (strokeStyleOrig > 0) {
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].color;
if (actualLinestyles != null && !((LINESTYLE2) actualLinestyles.lineStyles2[strokeStyleOrig]).hasFillFlag) {
RGBA color = (RGBA) actualLinestyles.lineStyles[strokeStyleOrig].getColor();
if (color.alpha == 0 && color.red == 0 && color.green == 0 && color.blue == 0) {
empty = true;
}
@@ -3011,7 +3012,6 @@ public class XFLConverter {
if (hasClipDepth) {
continue;
}*/
boolean nonEmpty = writeLayer(index, depthToFramesList.get(d), d, 0, Integer.MAX_VALUE, -1, writer, nonLibraryShapes, tags, timelineTags, characters, flaVersion, files);
if (nonEmpty) {
index++;