diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java index d54871ca1..c407b5c99 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java @@ -19,7 +19,9 @@ package com.jpexs.decompiler.flash.importers; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag; import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.tags.enums.ImageFormat; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; @@ -43,18 +45,26 @@ public class ShapeImporter { newData = baos.toByteArray(); } - DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, null, swf.getNextCharacterId(), newData); - jpeg2Tag.setModified(true); + ImageTag imageTag; + if (ImageTag.getImageFormat(newData) == ImageFormat.JPEG) { + DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, null, swf.getNextCharacterId(), newData); + imageTag = jpeg2Tag; + } else { + DefineBitsLossless2Tag lossless2Tag = new DefineBitsLossless2Tag(swf); + lossless2Tag.setImage(newData); + imageTag = lossless2Tag; + } + int idx = swf.tags.indexOf(st); if (idx != -1) { - swf.tags.add(idx, jpeg2Tag); + swf.tags.add(idx, imageTag); } else { - swf.tags.add(jpeg2Tag); + swf.tags.add(imageTag); } swf.updateCharacters(); st.setModified(true); - SHAPEWITHSTYLE shapes = jpeg2Tag.getShape(st.getRect(), true); + SHAPEWITHSTYLE shapes = imageTag.getShape(st.getRect(), true); st.shapes = shapes; return (Tag) st; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/UnknownTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/UnknownTag.java index 943f8af44..f7b8b98ef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/UnknownTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/UnknownTag.java @@ -27,6 +27,8 @@ import java.io.IOException; */ public class UnknownTag extends Tag { + private ByteArrayRange unknownData; + public UnknownTag(SWFInputStream sis, int id, ByteArrayRange data) throws IOException { super(sis.getSwf(), id, "Unknown", data); readData(sis, data, 0, false, false, false); @@ -34,6 +36,7 @@ public class UnknownTag extends Tag { @Override public final void readData(SWFInputStream sis, ByteArrayRange data, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException { + unknownData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available()); sis.skipBytes(sis.available()); } @@ -45,7 +48,7 @@ public class UnknownTag extends Tag { */ @Override public void getData(SWFOutputStream sos) throws IOException { - sos.write(getOriginalRange().getRangeData()); + sos.write(unknownData); } @Override