diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index ed25a9e51..3a77097e5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -72,6 +72,7 @@ public class DefineBinaryDataTag extends CharacterTag { public DefineBinaryDataTag(SWF swf) { super(swf, ID, "DefineBinaryData", null); tag = swf.getNextCharacterId(); + binaryData = new byte[0]; } public DefineBinaryDataTag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java index c40d03b58..1abc2ca3f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.SerializableImage; +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -63,7 +64,8 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag { @Override public SerializableImage getImage() { try { - return new SerializableImage(ImageIO.read(getImageData())); + BufferedImage image = ImageIO.read(getImageData()); + return image == null ? null : new SerializableImage(image); } catch (IOException ex) { } return null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java index 4690eae65..36493f0b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.SerializableImage; +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -89,7 +90,8 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { } else { stream = new ByteArrayInputStream(imageData); } - SerializableImage img = new SerializableImage(ImageIO.read(stream)); + BufferedImage image = ImageIO.read(stream); + SerializableImage img = image == null ? null : new SerializableImage(image); if (bitmapAlphaData.length == 0) { return img; } @@ -116,6 +118,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { super(swf, ID, "DefineBitsJPEG3", null); characterID = swf.getNextCharacterId(); imageData = new byte[0]; + bitmapAlphaData = new byte[0]; } public DefineBitsJPEG3Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java index 66ca034d2..7ed066c76 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.SerializableImage; +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -91,7 +92,8 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag { @Override public SerializableImage getImage() { try { - SerializableImage img = new SerializableImage(ImageIO.read(new ByteArrayInputStream(imageData))); + BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData)); + SerializableImage img = image == null ? null : new SerializableImage(image); if (bitmapAlphaData.length == 0) { return img; } @@ -140,6 +142,7 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag { super(swf, ID, "DefineBitsJPEG4", null); characterID = swf.getNextCharacterId(); imageData = new byte[0]; + bitmapAlphaData = new byte[0]; } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java index ce4b4a77f..8163c86b3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java @@ -36,6 +36,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.zip.InflaterInputStream; import javax.imageio.ImageIO; @@ -69,11 +71,30 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { return characterID; } + private byte[] createEmptyImage() { + try { + ALPHABITMAPDATA bitmapData = new ALPHABITMAPDATA(); + bitmapData.bitmapPixelData = new ARGB[1]; + bitmapData.bitmapPixelData[0] = new ARGB(); + bitmapData.bitmapPixelData[0].alpha = 0xff; + ByteArrayOutputStream bitmapDataOS = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, getVersion()); + sos.writeALPHABITMAPDATA(bitmapData, FORMAT_32BIT_ARGB, 1, 1); + ByteArrayOutputStream zlibOS = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion()); + sos2.writeBytesZlib(bitmapDataOS.toByteArray()); + return zlibOS.toByteArray(); + } catch (IOException ex) { + Logger.getLogger(DefineBitsLossless2Tag.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + @Override public void setImage(byte[] data) throws IOException { SerializableImage image = new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))); ALPHABITMAPDATA bitmapData = new ALPHABITMAPDATA(); - bitmapFormat = DefineBitsLosslessTag.FORMAT_24BIT_RGB; + bitmapFormat = FORMAT_32BIT_ARGB; bitmapWidth = image.getWidth(); bitmapHeight = image.getHeight(); bitmapData.bitmapPixelData = new ARGB[bitmapWidth * bitmapHeight]; @@ -116,8 +137,10 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { public DefineBitsLossless2Tag(SWF swf) { super(swf, ID, "DefineBitsLossless2", null); characterID = swf.getNextCharacterId(); + bitmapFormat = DefineBitsLossless2Tag.FORMAT_32BIT_ARGB; bitmapWidth = 1; bitmapHeight = 1; + zlibBitmapData = createEmptyImage(); } public DefineBitsLossless2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java index 2fbaf4661..00fca1a52 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java @@ -38,6 +38,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.zip.InflaterInputStream; import javax.imageio.ImageIO; @@ -73,6 +75,25 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { public static final int ID = 20; + private byte[] createEmptyImage() { + try { + BITMAPDATA bitmapData = new BITMAPDATA(); + bitmapData.bitmapPixelDataPix24 = new PIX24[1]; + bitmapData.bitmapPixelDataPix24[0] = new PIX24(); + bitmapData.bitmapPixelDataPix24[0].reserved = 0xff; + ByteArrayOutputStream bitmapDataOS = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, getVersion()); + sos.writeBITMAPDATA(bitmapData, FORMAT_24BIT_RGB, 1, 1); + ByteArrayOutputStream zlibOS = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion()); + sos2.writeBytesZlib(bitmapDataOS.toByteArray()); + return zlibOS.toByteArray(); + } catch (IOException ex) { + Logger.getLogger(DefineBitsLosslessTag.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + @Override public void setImage(byte[] data) throws IOException { SerializableImage image = new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))); @@ -190,8 +211,10 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { public DefineBitsLosslessTag(SWF swf) { super(swf, ID, "DefineBitsLossless", null); characterID = swf.getNextCharacterId(); + bitmapFormat = DefineBitsLosslessTag.FORMAT_24BIT_RGB; bitmapWidth = 1; bitmapHeight = 1; + zlibBitmapData = createEmptyImage(); } public DefineBitsLosslessTag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 5f6193657..419d1593f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -102,7 +102,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { super(swf, ID, "DefineButton", null); buttonId = swf.getNextCharacterId(); characters = new ArrayList<>(); - actionBytes = new ByteArrayRange(new byte[0]); + actionBytes = new ByteArrayRange(new byte[] {0}); } /** @@ -118,7 +118,11 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { characters = sis.readBUTTONRECORDList(false, "characters"); int pos = (int) sis.getPos(); byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes"); - actionBytes = new ByteArrayRange(data.array, pos, bytes.length); + if (data != null) { + actionBytes = new ByteArrayRange(data.array, pos, bytes.length); + } else { + actionBytes = new ByteArrayRange(bytes, 0, bytes.length); + } } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index fbaba4f60..aa54cb4ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -33,7 +33,9 @@ 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.MORPHFILLSTYLE; import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY; +import com.jpexs.decompiler.flash.types.MORPHLINESTYLE2; import com.jpexs.decompiler.flash.types.MORPHLINESTYLEARRAY; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; @@ -155,6 +157,16 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag public DefineMorphShape2Tag(SWF swf) { super(swf, ID, "DefineMorphShape2", null); characterId = swf.getNextCharacterId(); + startBounds = new RECT(); + endBounds = new RECT(); + startEdgeBounds = new RECT(); + endEdgeBounds = new RECT(); + startEdges = SHAPE.createEmpty(2); + endEdges = SHAPE.createEmpty(2); + morphFillStyles = new MORPHFILLSTYLEARRAY(); + morphFillStyles.fillStyles = new MORPHFILLSTYLE[0]; + morphLineStyles = new MORPHLINESTYLEARRAY(); + morphLineStyles.lineStyles2 = new MORPHLINESTYLE2[0]; } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 99a969601..2030d7bef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -33,7 +33,9 @@ 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.MORPHFILLSTYLE; import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY; +import com.jpexs.decompiler.flash.types.MORPHLINESTYLE; import com.jpexs.decompiler.flash.types.MORPHLINESTYLEARRAY; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; @@ -133,6 +135,14 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag { public DefineMorphShapeTag(SWF swf) { super(swf, ID, "DefineMorphShape", null); characterId = swf.getNextCharacterId(); + startBounds = new RECT(); + endBounds = new RECT(); + startEdges = SHAPE.createEmpty(1); + endEdges = SHAPE.createEmpty(1); + morphFillStyles = new MORPHFILLSTYLEARRAY(); + morphFillStyles.fillStyles = new MORPHFILLSTYLE[0]; + morphLineStyles = new MORPHLINESTYLEARRAY(); + morphLineStyles.lineStyles = new MORPHLINESTYLE[0]; } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java index 5882e6744..c42e4bd41 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java @@ -81,7 +81,7 @@ public class DefineShape2Tag extends ShapeTag { super(swf, ID, "DefineShape2", null); shapeId = swf.getNextCharacterId(); shapeBounds = new RECT(); - shapes = new SHAPEWITHSTYLE(); + shapes = SHAPEWITHSTYLE.createEmpty(2); } public DefineShape2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index 1c8ab932c..9c22fffb9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -81,6 +81,7 @@ public class DefineShape3Tag extends ShapeTag { super(swf, ID, "DefineShape3", null); shapeId = swf.getNextCharacterId(); shapeBounds = new RECT(); + shapes = SHAPEWITHSTYLE.createEmpty(3); } public DefineShape3Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index a2f17a8b3..76bc5ad29 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -88,6 +88,9 @@ public class DefineShape4Tag extends ShapeTag { public DefineShape4Tag(SWF swf) { super(swf, ID, "DefineShape4", null); shapeId = swf.getNextCharacterId(); + shapeBounds = new RECT(); + edgeBounds = new RECT(); + shapes = SHAPEWITHSTYLE.createEmpty(4); } public DefineShape4Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index c6b0a347a..2b9a5fe09 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -75,7 +75,7 @@ public class DefineShapeTag extends ShapeTag { super(swf, ID, "DefineShape", null); shapeId = swf.getNextCharacterId(); shapeBounds = new RECT(); - shapes = new SHAPEWITHSTYLE(); + shapes = SHAPEWITHSTYLE.createEmpty(1); } public DefineShapeTag(SWFInputStream sis, ByteArrayRange data) throws IOException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java index aadef9e66..94b3bda83 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java @@ -103,6 +103,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { public DefineSoundTag(SWF swf) { super(swf, ID, "DefineSound", null); soundId = swf.getNextCharacterId(); + soundData = new byte[] {0}; } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 2e84c1c78..01285adcf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -481,6 +481,7 @@ public class DefineText2Tag extends TextTag { super(swf, ID, "DefineText2", null); characterID = swf.getNextCharacterId(); textBounds = new RECT(); + textMatrix = new MATRIX(); textRecords = new ArrayList<>(); glyphBits = 0; advanceBits = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index c6e83c3cf..ceabc393d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -443,6 +443,7 @@ public class DefineTextTag extends TextTag { characterID = swf.getNextCharacterId(); textBounds = new RECT(); textMatrix = new MATRIX(); + textRecords = new ArrayList<>(); glyphBits = 0; advanceBits = 0; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index ce4ce7d77..67f26b7b6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -88,8 +88,12 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { public DefineCompactedFont(SWF swf) { super(swf, ID, "DefineCompactedFont", null); fontId = swf.getNextCharacterId(); + fonts = new ArrayList<>(); - shapeCache = new ArrayList<>(); + FontType ft = new FontType(); + fonts.add(ft); + + rebuildShapeCache(); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java index 54e3f54a0..c7a4e8d6d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -12,17 +12,20 @@ * 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.exporters.shape.PathExporter; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.annotations.SWFType; +import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import java.awt.Shape; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -67,4 +70,11 @@ public class SHAPE implements NeedsCharacters, Serializable { return area; } + + public static SHAPE createEmpty(int shapeNum) { + SHAPE ret = new SHAPE(); + ret.shapeRecords = new ArrayList<>(); + ret.shapeRecords.add(new EndShapeRecord()); + return ret; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java index 79d24d392..54d729ff9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java @@ -12,12 +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.types; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; +import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import java.io.Serializable; +import java.util.ArrayList; import java.util.Set; /** @@ -48,4 +51,20 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab } return modified; } + + public static SHAPEWITHSTYLE createEmpty(int shapeNum) { + SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE(); + ret.shapeRecords = new ArrayList<>(); + ret.shapeRecords.add(new EndShapeRecord()); + ret.fillStyles = new FILLSTYLEARRAY(); + ret.fillStyles.fillStyles = new FILLSTYLE[0]; + ret.lineStyles = new LINESTYLEARRAY(); + if ((shapeNum == 1 || shapeNum == 2 || shapeNum == 3)) { + ret.lineStyles.lineStyles = new LINESTYLE[0]; + } else if (shapeNum == 4) { + ret.lineStyles.lineStyles = new LINESTYLE2[0]; + } + + return ret; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java index 79a871082..dc0e60923 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java @@ -41,6 +41,13 @@ public class FontType implements Serializable { public List glyphInfo; public List kerning; + public FontType() { + fontName = "New font"; + glyphInfo = new ArrayList<>(); + kerning = new ArrayList<>(); + glyphs = new ArrayList<>(); + } + public FontType(GFxInputStream sis) throws IOException { long offset = sis.getPos(); fontName = sis.readString("fontName"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java index a774712d2..cbc48ce31 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java @@ -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.helpers; import java.awt.AlphaComposite; diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index cbb6be40b..b57c7fe4d 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -115,7 +115,6 @@ public class TagTree extends JTree implements ActionListener { private static final String ACTION_REMOVE_ITEM = "REMOVEITEM"; private static final String ACTION_REMOVE_ITEM_WITH_DEPENDENCIES = "REMOVEITEMWITHDEPENDENCIES"; private static final String ACTION_CLOSE_SWF = "CLOSESWF"; - private static final String ACTION_ADD_TAG = "ADDTAG"; private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE"; private static final String ACTION_OPEN_SWFINSIDE = "OPENSWFINSIDE"; @@ -309,7 +308,7 @@ public class TagTree extends JTree implements ActionListener { return TreeNodeType.FOLDER; } - public List getTreeItemClasses(String folderName) { + public List getTreeItemClasses(String folderName, boolean gfx) { List ret = null; switch (folderName) { case TagTreeModel.FOLDER_SHAPES: @@ -337,7 +336,10 @@ public class TagTree extends JTree implements ActionListener { ret = Arrays.asList((Class) DefineButtonTag.class, DefineButton2Tag.class); break; case TagTreeModel.FOLDER_FONTS: - ret = Arrays.asList((Class) DefineFontTag.class, DefineFont2Tag.class, DefineFont3Tag.class, DefineFont4Tag.class, DefineCompactedFont.class); + ret = Arrays.asList((Class) DefineFontTag.class, DefineFont2Tag.class, DefineFont3Tag.class, DefineFont4Tag.class); + if (gfx) { + ret.add(DefineCompactedFont.class); + } break; case TagTreeModel.FOLDER_BINARY_DATA: ret = Arrays.asList((Class) DefineBinaryDataTag.class); @@ -474,28 +476,30 @@ public class TagTree extends JTree implements ActionListener { if (item instanceof FolderItem) { final FolderItem folderItem = (FolderItem) item; - List allowedTagTypes = getTreeItemClasses(folderItem.getName()); + List allowedTagTypes = getTreeItemClasses(folderItem.getName(), item.getSwf().gfx); addTagMenu.removeAll(); - for (final Class cl : allowedTagTypes) { - JMenuItem tagItem = new JMenuItem(cl.getSimpleName()); - tagItem.addActionListener(new ActionListener() { + if (allowedTagTypes != null) { + for (final Class cl : allowedTagTypes) { + JMenuItem tagItem = new JMenuItem(cl.getSimpleName()); + tagItem.addActionListener(new ActionListener() { - @Override - @SuppressWarnings("unchecked") - public void actionPerformed(ActionEvent ae) { - try { - SWF swf = folderItem.getSwf(); - swf.tags.add((Tag) cl.getDeclaredConstructor(SWF.class).newInstance(new Object[]{swf})); - swf.updateCharacters(); - mainPanel.refreshTree(); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { - Logger.getLogger(TagTree.class.getName()).log(Level.SEVERE, null, ex); + @Override + @SuppressWarnings("unchecked") + public void actionPerformed(ActionEvent ae) { + try { + SWF swf = folderItem.getSwf(); + swf.tags.add((Tag) cl.getDeclaredConstructor(SWF.class).newInstance(new Object[]{swf})); + swf.updateCharacters(); + mainPanel.refreshTree(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { + Logger.getLogger(TagTree.class.getName()).log(Level.SEVERE, null, ex); + } } - } - }); - addTagMenu.add(tagItem); + }); + addTagMenu.add(tagItem); + } + addTagMenu.setVisible(true); } - addTagMenu.setVisible(true); } if (item instanceof Tag && swfs.size() > 1) {