From 644110dd406bf5ccc658cf2bea6710512a5083fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 4 Jan 2013 17:12:27 +0100 Subject: [PATCH] New tags, Other code: organize imports --- trunk/src/com/jpexs/asdec/Main.java | 4 +- trunk/src/com/jpexs/asdec/SWF.java | 67 ++- trunk/src/com/jpexs/asdec/SWFInputStream.java | 425 ++++++++++++++++-- .../src/com/jpexs/asdec/SWFOutputStream.java | 420 ++++++++++++++++- .../com/jpexs/asdec/abc/CopyOutputStream.java | 35 +- .../construction/ConstructIns.java | 2 +- .../avm2/instructions/xml/DXNSLateIns.java | 2 - .../avm2/instructions/xml/EscXAttrIns.java | 1 - .../avm2/treemodel/DefaultXMLNamespace.java | 12 +- .../com/jpexs/asdec/abc/gui/MainFrame.java | 2 - trunk/src/com/jpexs/asdec/action/TagNode.java | 4 +- .../com/jpexs/asdec/action/gui/MainFrame.java | 2 +- .../jpexs/asdec/tags/CSMTextSettingsTag.java | 90 ++++ .../src/com/jpexs/asdec/tags/DebugIDTag.java | 2 - .../jpexs/asdec/tags/DefineBinaryDataTag.java | 35 +- .../jpexs/asdec/tags/DefineBitsJPEG2Tag.java | 13 +- .../jpexs/asdec/tags/DefineBitsJPEG3Tag.java | 40 +- .../jpexs/asdec/tags/DefineBitsJPEG4Tag.java | 86 ++++ .../asdec/tags/DefineBitsLossless2Tag.java | 50 ++- .../asdec/tags/DefineBitsLosslessTag.java | 54 ++- .../com/jpexs/asdec/tags/DefineBitsTag.java | 35 +- .../jpexs/asdec/tags/DefineButton2Tag.java | 4 +- .../jpexs/asdec/tags/DefineButtonCxform.java | 79 ++++ .../asdec/tags/DefineButtonSoundTag.java | 116 +++++ .../com/jpexs/asdec/tags/DefineButtonTag.java | 4 +- .../jpexs/asdec/tags/DefineEditTextTag.java | 194 ++++++++ .../com/jpexs/asdec/tags/DefineFont2Tag.java | 219 +++++++++ .../com/jpexs/asdec/tags/DefineFont3Tag.java | 164 ++++++- .../com/jpexs/asdec/tags/DefineFont4Tag.java | 49 +- .../asdec/tags/DefineFontAlignZonesTag.java | 48 +- .../jpexs/asdec/tags/DefineFontInfo2Tag.java | 112 +++++ .../jpexs/asdec/tags/DefineFontInfoTag.java | 118 +++++ .../jpexs/asdec/tags/DefineFontNameTag.java | 6 +- .../com/jpexs/asdec/tags/DefineFontTag.java | 36 +- .../asdec/tags/DefineMorphShape2Tag.java | 117 +++++ .../jpexs/asdec/tags/DefineMorphShapeTag.java | 104 +++++ .../tags/DefineSceneAndFrameLabelDataTag.java | 2 - .../com/jpexs/asdec/tags/DefineShape2Tag.java | 8 +- .../com/jpexs/asdec/tags/DefineShape4Tag.java | 16 +- .../com/jpexs/asdec/tags/DefineShapeTag.java | 9 +- .../com/jpexs/asdec/tags/DefineSoundTag.java | 98 ++++ .../com/jpexs/asdec/tags/DefineSpriteTag.java | 4 +- .../com/jpexs/asdec/tags/DefineText2Tag.java | 102 +++++ .../com/jpexs/asdec/tags/DefineTextTag.java | 39 +- .../asdec/tags/DefineVideoStreamTag.java | 95 ++++ .../src/com/jpexs/asdec/tags/DoActionTag.java | 2 +- .../com/jpexs/asdec/tags/DoInitActionTag.java | 4 +- .../jpexs/asdec/tags/EnableDebugger2Tag.java | 5 +- trunk/src/com/jpexs/asdec/tags/EndTag.java | 7 - .../com/jpexs/asdec/tags/ExportAssetsTag.java | 4 +- .../jpexs/asdec/tags/FileAttributesTag.java | 47 +- .../com/jpexs/asdec/tags/JPEGTablesTag.java | 3 +- .../src/com/jpexs/asdec/tags/MetadataTag.java | 7 +- .../com/jpexs/asdec/tags/NotDefinedTag.java | 8 +- .../com/jpexs/asdec/tags/PlaceObject2Tag.java | 2 +- .../com/jpexs/asdec/tags/PlaceObject3Tag.java | 2 +- .../com/jpexs/asdec/tags/ProductInfoTag.java | 14 +- .../jpexs/asdec/tags/RemoveObject2Tag.java | 2 +- .../com/jpexs/asdec/tags/ScriptLimitsTag.java | 6 +- .../asdec/tags/SetBackgroundColorTag.java | 2 +- .../com/jpexs/asdec/tags/SetTabIndexTag.java | 2 +- .../jpexs/asdec/tags/SoundStreamBlockTag.java | 48 ++ .../jpexs/asdec/tags/SoundStreamHead2Tag.java | 105 +++++ .../jpexs/asdec/tags/SoundStreamHeadTag.java | 105 +++++ .../com/jpexs/asdec/tags/StartSound2Tag.java | 78 ++++ .../com/jpexs/asdec/tags/StartSoundTag.java | 79 ++++ .../com/jpexs/asdec/tags/SymbolClassTag.java | 4 +- trunk/src/com/jpexs/asdec/tags/Tag.java | 9 + .../asdec/tags/{StubTag.java => TagStub.java} | 8 +- .../com/jpexs/asdec/tags/VideoFrameTag.java | 81 ++++ trunk/src/com/jpexs/asdec/types/CXFORM.java | 4 - .../src/com/jpexs/asdec/types/FILLSTYLE.java | 19 +- .../com/jpexs/asdec/types/FILLSTYLEARRAY.java | 1 + .../com/jpexs/asdec/types/FOCALGRADIENT.java | 3 +- .../src/com/jpexs/asdec/types/GLYPHENTRY.java | 27 ++ trunk/src/com/jpexs/asdec/types/GRADIENT.java | 22 +- .../src/com/jpexs/asdec/types/GRADRECORD.java | 2 +- .../com/jpexs/asdec/types/KERNINGRECORD.java | 29 ++ trunk/src/com/jpexs/asdec/types/LANGCODE.java | 26 ++ .../src/com/jpexs/asdec/types/LINESTYLE.java | 2 +- .../src/com/jpexs/asdec/types/LINESTYLE2.java | 18 +- .../com/jpexs/asdec/types/LINESTYLEARRAY.java | 1 + .../com/jpexs/asdec/types/MORPHFILLSTYLE.java | 41 ++ .../asdec/types/MORPHFILLSTYLEARRAY.java | 26 ++ .../com/jpexs/asdec/types/MORPHGRADIENT.java | 27 ++ .../jpexs/asdec/types/MORPHGRADRECORD.java | 29 ++ .../com/jpexs/asdec/types/MORPHLINESTYLE.java | 29 ++ .../jpexs/asdec/types/MORPHLINESTYLE2.java | 45 ++ .../asdec/types/MORPHLINESTYLEARRAY.java | 27 ++ trunk/src/com/jpexs/asdec/types/SHAPE.java | 1 + .../com/jpexs/asdec/types/SHAPEWITHSTYLE.java | 3 +- .../com/jpexs/asdec/types/SOUNDENVELOPE.java | 28 ++ .../src/com/jpexs/asdec/types/SOUNDINFO.java | 35 ++ .../src/com/jpexs/asdec/types/TEXTRECORD.java | 36 ++ trunk/src/com/jpexs/asdec/types/ZONEDATA.java | 28 ++ .../src/com/jpexs/asdec/types/ZONERECORD.java | 29 ++ .../types/shaperecords/CurvedEdgeRecord.java | 13 +- .../types/shaperecords/EndShapeRecord.java | 12 +- .../asdec/types/shaperecords/SHAPERECORD.java | 1 - .../shaperecords/StraightEdgeRecord.java | 15 +- .../types/shaperecords/StyleChangeRecord.java | 13 +- 101 files changed, 4051 insertions(+), 299 deletions(-) create mode 100644 trunk/src/com/jpexs/asdec/tags/CSMTextSettingsTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG4Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineButtonCxform.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineButtonSoundTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineEditTextTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineFont2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineFontInfo2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineFontInfoTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineMorphShape2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineMorphShapeTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineSoundTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineText2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/DefineVideoStreamTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/SoundStreamBlockTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/SoundStreamHead2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/SoundStreamHeadTag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/StartSound2Tag.java create mode 100644 trunk/src/com/jpexs/asdec/tags/StartSoundTag.java rename trunk/src/com/jpexs/asdec/tags/{StubTag.java => TagStub.java} (88%) create mode 100644 trunk/src/com/jpexs/asdec/tags/VideoFrameTag.java create mode 100644 trunk/src/com/jpexs/asdec/types/GLYPHENTRY.java create mode 100644 trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java create mode 100644 trunk/src/com/jpexs/asdec/types/LANGCODE.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLE.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLEARRAY.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHGRADIENT.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHGRADRECORD.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE2.java create mode 100644 trunk/src/com/jpexs/asdec/types/MORPHLINESTYLEARRAY.java create mode 100644 trunk/src/com/jpexs/asdec/types/SOUNDENVELOPE.java create mode 100644 trunk/src/com/jpexs/asdec/types/SOUNDINFO.java create mode 100644 trunk/src/com/jpexs/asdec/types/TEXTRECORD.java create mode 100644 trunk/src/com/jpexs/asdec/types/ZONEDATA.java create mode 100644 trunk/src/com/jpexs/asdec/types/ZONERECORD.java diff --git a/trunk/src/com/jpexs/asdec/Main.java b/trunk/src/com/jpexs/asdec/Main.java index 694d189a7..51b2c6f30 100644 --- a/trunk/src/com/jpexs/asdec/Main.java +++ b/trunk/src/com/jpexs/asdec/Main.java @@ -523,7 +523,7 @@ public class Main { System.err.println("FAIL"); } } else if (args[pos].equals("-decompress")) { - if (args.length < pos+3) { + if (args.length < pos + 3) { badArguments(); } @@ -535,7 +535,7 @@ public class Main { System.exit(1); } } else if (args[pos].equals("-dumpSWF")) { - if (args.length < pos+2) { + if (args.length < pos + 2) { badArguments(); } try { diff --git a/trunk/src/com/jpexs/asdec/SWF.java b/trunk/src/com/jpexs/asdec/SWF.java index 468bf6485..d5f1c4ede 100644 --- a/trunk/src/com/jpexs/asdec/SWF.java +++ b/trunk/src/com/jpexs/asdec/SWF.java @@ -19,9 +19,9 @@ package com.jpexs.asdec; import SevenZip.Compression.LZMA.Encoder; import com.jpexs.asdec.action.TagNode; import com.jpexs.asdec.helpers.Highlighting; -import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.tags.DoABCTag; import com.jpexs.asdec.tags.Tag; +import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.tags.base.TagName; import com.jpexs.asdec.types.RECT; import java.io.*; @@ -287,8 +287,7 @@ public class SWF { } return true; } - - + /** * Decompress LZMA compressed SWF file * @@ -298,40 +297,40 @@ public class SWF { public static boolean zws2fws(InputStream fis, OutputStream fos) { try { byte hdr[] = new byte[3]; - fis.read(hdr); - String shdr = new String(hdr); - if (!shdr.equals("ZWS")) { - return false; - } - int version = fis.read(); - SWFInputStream sis = new SWFInputStream(fis, version, 4); - long fileSize = sis.readUI32(); + fis.read(hdr); + String shdr = new String(hdr); + if (!shdr.equals("ZWS")) { + return false; + } + int version = fis.read(); + SWFInputStream sis = new SWFInputStream(fis, version, 4); + long fileSize = sis.readUI32(); - if (hdr[0] == 'Z') { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - long outSize = sis.readUI32(); - int propertiesSize = 5; - byte lzmaProperties[] = new byte[propertiesSize]; - if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { - throw new IOException("LZMA:input .lzma file is too short"); - } - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); - if (!decoder.SetDecoderProperties(lzmaProperties)) { - throw new IOException("LZMA:Incorrect stream properties"); - } + if (hdr[0] == 'Z') { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long outSize = sis.readUI32(); + int propertiesSize = 5; + byte lzmaProperties[] = new byte[propertiesSize]; + if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { + throw new IOException("LZMA:input .lzma file is too short"); + } + SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); + if (!decoder.SetDecoderProperties(lzmaProperties)) { + throw new IOException("LZMA:Incorrect stream properties"); + } - if (!decoder.Code(sis, baos, fileSize - 8)) { - throw new IOException("LZMA:Error in data stream"); + if (!decoder.Code(sis, baos, fileSize - 8)) { + throw new IOException("LZMA:Error in data stream"); + } + SWFOutputStream sos = new SWFOutputStream(fos, version); + sos.write("FWS".getBytes()); + sos.write(version); + sos.writeUI32(fileSize); + sos.write(baos.toByteArray()); + sos.close(); + } else { + return false; } - SWFOutputStream sos=new SWFOutputStream(fos,version); - sos.write("FWS".getBytes()); - sos.write(version); - sos.writeUI32(fileSize); - sos.write(baos.toByteArray()); - sos.close(); - }else{ - return false; - } } catch (FileNotFoundException ex) { return false; } catch (IOException ex) { diff --git a/trunk/src/com/jpexs/asdec/SWFInputStream.java b/trunk/src/com/jpexs/asdec/SWFInputStream.java index e9649ecec..94d4b218b 100644 --- a/trunk/src/com/jpexs/asdec/SWFInputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFInputStream.java @@ -38,6 +38,7 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.Stack; +import java.util.logging.Logger; /** * Class for reading data from SWF file @@ -50,6 +51,7 @@ public class SWFInputStream extends InputStream { private Stack margedPos = new Stack(); private long pos; private int version; + private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); /** * Constructor @@ -405,6 +407,7 @@ public class SWFInputStream extends InputStream { ret.Xmax = (int) readSB(NBits); ret.Ymin = (int) readSB(NBits); ret.Ymax = (int) readSB(NBits); + alignByte(); return ret; } @@ -511,7 +514,7 @@ public class SWFInputStream extends InputStream { break; case 8: ret = new JPEGTablesTag(data, pos); - break; + break; case 9: ret = new SetBackgroundColorTag(data, pos); break; @@ -525,23 +528,23 @@ public class SWFInputStream extends InputStream { ret = new DoActionTag(data, version, pos); break; case 13: - ret = new NotDefinedTag("DefineFontInfo",13,data,pos); + ret = new DefineFontInfoTag(data, version, pos); break; case 14: - ret = new NotDefinedTag("DefineSound",14,data,pos); + ret = new DefineSoundTag(data, version, pos); break; case 15: - ret = new NotDefinedTag("StartSound",15,data,pos); + ret = new StartSoundTag(data, version, pos); break; //case 16 case 17: - ret = new NotDefinedTag("DefineButtonSound",17,data,pos); + ret = new DefineButtonSoundTag(data, version, pos); break; case 18: - ret = new NotDefinedTag("SoundStreamHead",18,data,pos); + ret = new SoundStreamHeadTag(data, version, pos); break; case 19: - ret = new NotDefinedTag("SoundStreamBlock",19,data,pos); + ret = new SoundStreamBlockTag(data, version, pos); break; case 21: ret = new DefineBitsJPEG2Tag(data, version, pos); @@ -553,8 +556,8 @@ public class SWFInputStream extends InputStream { ret = new DefineShape2Tag(data, version, pos); break; case 23: - ret = new NotDefinedTag("DefineButtonCxform",23,data,pos); - break; + ret = new DefineButtonCxform(data, version, pos); + break; case 24: ret = new ProtectTag(data, version, pos); break; @@ -573,8 +576,8 @@ public class SWFInputStream extends InputStream { ret = new DefineShape3Tag(data, version, pos); break; case 33: - ret = new NotDefinedTag("DefineText2",33,data,pos); - break; + ret = new DefineText2Tag(data, version, pos); + break; case 34: ret = new DefineButton2Tag(data, version, pos); break; @@ -585,8 +588,8 @@ public class SWFInputStream extends InputStream { ret = new DefineBitsLossless2Tag(data, version, pos); break; case 37: - ret = new NotDefinedTag("DefineEditText",37,data,pos); - break; + ret = new DefineEditTextTag(data, version, pos); + break; //case 38: case 39: ret = new DefineSpriteTag(data, version, level, pos); @@ -601,14 +604,14 @@ public class SWFInputStream extends InputStream { break; //case 44: case 45: - ret = new NotDefinedTag("SoundStreamHead2",45,data,pos); + ret = new SoundStreamHead2Tag(data, version, pos); break; case 46: - ret = new NotDefinedTag("DefineMorphShape",46,data,pos); + ret = new DefineMorphShapeTag(data, version, pos); break; //case 47: case 48: - ret = new NotDefinedTag("DefineFont2",48,data,pos); + ret = new DefineFont2Tag(data, version, pos); break; //case 49-55: case 56: @@ -619,25 +622,25 @@ public class SWFInputStream extends InputStream { break; case 58: ret = new EnableDebuggerTag(data, version, pos); - break; + break; case 59: ret = new DoInitActionTag(data, version, pos); - break; + break; case 60: - ret = new NotDefinedTag("DefineVideoStream",60,data,pos); + ret = new DefineVideoStreamTag(data, version, pos); break; case 61: - ret = new NotDefinedTag("VideoFrame",61,data,pos); + ret = new VideoFrameTag(data, version, pos); break; case 62: - ret = new NotDefinedTag("DefineFontInfo2",62,data,pos); + ret = new DefineFontInfo2Tag(data, version, pos); break; case 63: ret = new DebugIDTag(data, version, pos); break; case 64: ret = new EnableDebugger2Tag(data, version, pos); - break; + break; case 65: ret = new ScriptLimitsTag(data, version, pos); break; @@ -650,16 +653,16 @@ public class SWFInputStream extends InputStream { break; case 70: ret = new PlaceObject3Tag(data, version, pos); - break; + break; case 71: ret = new ImportAssets2Tag(data, version, pos); - break; + break; //case 72: case 73: ret = new DefineFontAlignZonesTag(data, version, pos); break; case 74: - ret = new NotDefinedTag("DefineFontInfo2",62,data,pos); + ret = new CSMTextSettingsTag(data, version, pos); break; case 75: ret = new DefineFont3Tag(data, version, pos); @@ -679,9 +682,9 @@ public class SWFInputStream extends InputStream { break; case 83: ret = new DefineShape4Tag(data, version, pos); - break; + break; case 84: - ret = new NotDefinedTag("DefineMorphShape2",84,data,pos); + ret = new DefineMorphShape2Tag(data, version, pos); break; //case 85: case 86: @@ -689,15 +692,15 @@ public class SWFInputStream extends InputStream { break; case 87: ret = new DefineBinaryDataTag(data, version, pos); - break; + break; case 88: ret = new DefineFontNameTag(data, version, pos); break; case 89: - ret = new NotDefinedTag("StartSound2",89,data,pos); + ret = new StartSound2Tag(data, version, pos); break; case 90: - ret = new NotDefinedTag("DefineBitsJPEG4",84,data,pos); + ret = new DefineBitsJPEG4Tag(data, version, pos); break; case 91: ret = new DefineFont4Tag(data, version, pos); @@ -706,6 +709,39 @@ public class SWFInputStream extends InputStream { ret = new Tag(tagID, data, pos); } ret.forceWriteAsLong = readLong; + byte dataNew[] = ret.getData(version); + + int ignoreFirst = 0; + for (int i = 0; i < data.length; i++) { + if (i >= dataNew.length) { + break; + } + if (dataNew[i] != data[i]) { + if (ignoreFirst > 0) { + ignoreFirst--; + continue; + } + String e = ""; + e = ("TAG " + ret.toString() + " WRONG, "); + for (int j = i - 10; j <= i + 5; j++) { + while (j < 0) { + j++; + } + if (j >= data.length) { + break; + } + if (j >= dataNew.length) { + break; + } + if (j >= i) { + e += (Long.toHexString(data[j] & 0xff) + " ( is " + Long.toHexString(dataNew[j] & 0xff) + ") "); + } else { + e += (Long.toHexString(data[j] & 0xff) + " "); + } + } + log.severe(e); + } + } return ret; } @@ -1564,6 +1600,7 @@ public class SWFInputStream extends InputStream { FILLSTYLEARRAY ret = new FILLSTYLEARRAY(); int fillStyleCount = readUI8(); + if (((shapeNum == 2) || (shapeNum == 3)) && (fillStyleCount == 0xff)) { fillStyleCount = readUI16(); } @@ -1700,7 +1737,7 @@ public class SWFInputStream extends InputStream { ser.numBits = (int) readUB(4); ser.generalLineFlag = readUB(1) == 1; if (!ser.generalLineFlag) { - ser.vertLineFlag = readSB(1) == 1; + ser.vertLineFlag = readUB(1) == 1; } if (ser.generalLineFlag || (!ser.vertLineFlag)) { ser.deltaX = (int) readSB(ser.numBits + 2); @@ -1771,6 +1808,332 @@ public class SWFInputStream extends InputStream { } ret.add(rec); } while (!(rec instanceof EndShapeRecord)); + alignByte(); + return ret; + } + + /** + * Reads one SOUNDINFO value from the stream + * + * @return SOUNDINFO value + * @throws IOException + */ + public SOUNDINFO readSOUNDINFO() throws IOException { + SOUNDINFO ret = new SOUNDINFO(); + readUB(2); + ret.syncStop = readUB(1) == 1; + ret.syncNoMultiple = readUB(1) == 1; + ret.hasEnvelope = readUB(1) == 1; + ret.hasLoops = readUB(1) == 1; + ret.hasOutPoint = readUB(1) == 1; + ret.hasInPoint = readUB(1) == 1; + if (ret.hasInPoint) { + ret.inPoint = readUI32(); + } + if (ret.hasOutPoint) { + ret.outPoint = readUI32(); + } + if (ret.hasLoops) { + ret.loopCount = readUI16(); + } + if (ret.hasEnvelope) { + int envPoints = readUI8(); + ret.envelopeRecords = new SOUNDENVELOPE[envPoints]; + for (int i = 0; i < envPoints; i++) { + ret.envelopeRecords[i] = readSOUNDENVELOPE(); + } + } + return ret; + } + + /** + * Reads one SOUNDENVELOPE value from the stream + * + * @return SOUNDENVELOPE value + * @throws IOException + */ + public SOUNDENVELOPE readSOUNDENVELOPE() throws IOException { + SOUNDENVELOPE ret = new SOUNDENVELOPE(); + ret.pos44 = readUI32(); + ret.leftLevel = readUI16(); + ret.rightLevel = readUI16(); + return ret; + } + + /** + * Reads one GLYPHENTRY value from the stream + * + * @return GLYPHENTRY value + * @throws IOException + */ + public GLYPHENTRY readGLYPHENTRY(int glyphBits, int advanceBits) throws IOException { + GLYPHENTRY ret = new GLYPHENTRY(); + ret.glyphIndex = (int) readUB(glyphBits); + ret.glyphAdvance = (int) readUB(advanceBits); + return ret; + } + + /** + * Reads one TEXTRECORD value from the stream + * + * @return TEXTRECORD value + * @throws IOException + */ + public TEXTRECORD readTEXTRECORD(boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { + TEXTRECORD ret = new TEXTRECORD(); + int first = (int) readUB(1); //always 1 + readUB(3); //always 0 + ret.styleFlagsHasFont = readUB(1) == 1; + ret.styleFlagsHasColor = readUB(1) == 1; + ret.styleFlagsHasYOffset = readUB(1) == 1; + ret.styleFlagsHasXOffset = readUB(1) == 1; + if ((!ret.styleFlagsHasFont) && (!ret.styleFlagsHasColor) && (!ret.styleFlagsHasYOffset) && (!ret.styleFlagsHasXOffset) && (first == 0)) { //final text record + return null; + } + if (ret.styleFlagsHasFont) { + ret.fontId = readUI16(); + } + if (ret.styleFlagsHasColor) { + if (inDefineText2) { + ret.textColorA = readRGBA(); + } else { + ret.textColor = readRGB(); + } + } + if (ret.styleFlagsHasXOffset) { + ret.xOffset = readSI16(); + } + if (ret.styleFlagsHasYOffset) { + ret.yOffset = readSI16(); + } + if (ret.styleFlagsHasFont) { + ret.textHeight = readUI16(); + } + int glyphCount = readUI8(); + ret.glyphEntries = new GLYPHENTRY[glyphCount]; + for (int i = 0; i < glyphCount; i++) { + ret.glyphEntries[i] = readGLYPHENTRY(glyphBits, advanceBits); + } + return ret; + } + + /** + * Reads one MORPHGRADRECORD value from the stream + * + * @return MORPHGRADRECORD value + * @throws IOException + */ + public MORPHGRADRECORD readMORPHGRADRECORD() throws IOException { + MORPHGRADRECORD ret = new MORPHGRADRECORD(); + ret.startRatio = readUI8(); + ret.startColor = readRGBA(); + ret.endRatio = readUI8(); + ret.endColor = readRGBA(); + return ret; + } + + /** + * Reads one MORPHGRADIENT value from the stream + * + * @return MORPHGRADIENT value + * @throws IOException + */ + public MORPHGRADIENT readMORPHGRADIENT() throws IOException { + MORPHGRADIENT ret = new MORPHGRADIENT(); + int numGradients = (int) readUI8(); + ret.gradientRecords = new MORPHGRADRECORD[numGradients]; + for (int i = 0; i < numGradients; i++) { + ret.gradientRecords[i] = readMORPHGRADRECORD(); + } + return ret; + } + + /** + * Reads one MORPHFILLSTYLE value from the stream + * + * @return MORPHFILLSTYLE value + * @throws IOException + */ + public MORPHFILLSTYLE readMORPHFILLSTYLE() throws IOException { + MORPHFILLSTYLE ret = new MORPHFILLSTYLE(); + ret.fillStyleType = readUI8(); + if (ret.fillStyleType == MORPHFILLSTYLE.SOLID) { + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + } + if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + ret.startGradientMatrix = readMatrix(); + ret.endGradientMatrix = readMatrix(); + } + if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + ret.gradient = readMORPHGRADIENT(); + } + + if ((ret.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + ret.bitmapId = readUI16(); + ret.startBitmapMatrix = readMatrix(); + ret.endBitmapMatrix = readMatrix(); + } + return ret; + } + + /** + * Reads one MORPHFILLSTYLEARRAY value from the stream + * + * @return MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public MORPHFILLSTYLEARRAY readMORPHFILLSTYLEARRAY() throws IOException { + + MORPHFILLSTYLEARRAY ret = new MORPHFILLSTYLEARRAY(); + int fillStyleCount = readUI8(); + if (fillStyleCount == 0xff) { + fillStyleCount = readUI16(); + } + ret.fillStyles = new MORPHFILLSTYLE[fillStyleCount]; + for (int i = 0; i < fillStyleCount; i++) { + ret.fillStyles[i] = readMORPHFILLSTYLE(); + } + return ret; + } + + /** + * Reads one MORPHLINESTYLE value from the stream + * + * @return MORPHLINESTYLE value + * @throws IOException + */ + public MORPHLINESTYLE readMORPHLINESTYLE() throws IOException { + MORPHLINESTYLE ret = new MORPHLINESTYLE(); + ret.startWidth = readUI16(); + ret.endWidth = readUI16(); + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + return ret; + } + + /** + * Reads one MORPHLINESTYLE2 value from the stream + * + * @return MORPHLINESTYLE2 value + * @throws IOException + */ + public MORPHLINESTYLE2 readMORPHLINESTYLE2() throws IOException { + MORPHLINESTYLE2 ret = new MORPHLINESTYLE2(); + ret.startWidth = readUI16(); + ret.endWidth = readUI16(); + ret.startCapStyle = (int) readUB(2); + ret.joinStyle = (int) readUB(2); + ret.hasFillFlag = (int) readUB(1) == 1; + ret.noHScaleFlag = (int) readUB(1) == 1; + ret.noVScaleFlag = (int) readUB(1) == 1; + ret.pixelHintingFlag = (int) readUB(1) == 1; + readUB(5);//reserved + ret.noClose = (int) readUB(1) == 1; + ret.endCapStyle = (int) readUB(2); + if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { + ret.miterLimitFactor = readUI16(); + } + if (!ret.hasFillFlag) { + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + } else { + ret.fillType = readMORPHFILLSTYLE(); + } + return ret; + } + + /** + * Reads one MORPHLINESTYLEARRAY value from the stream + * + * @return MORPHLINESTYLEARRAY value + * @throws IOException + */ + public MORPHLINESTYLEARRAY readMORPHLINESTYLEARRAY(int morphShapeNum) throws IOException { + MORPHLINESTYLEARRAY ret = new MORPHLINESTYLEARRAY(); + int lineStyleCount = readUI8(); + if (lineStyleCount == 0xff) { + lineStyleCount = readUI16(); + } + if (morphShapeNum == 1) { + ret.lineStyles = new MORPHLINESTYLE[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles[i] = readMORPHLINESTYLE(); + } + } else if (morphShapeNum == 2) { + ret.lineStyles2 = new MORPHLINESTYLE2[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles2[i] = readMORPHLINESTYLE2(); + } + } + return ret; + } + + /** + * Reads one KERNINGRECORD value from the stream + * + * @return KERNINGRECORD value + * @throws IOException + */ + public KERNINGRECORD readKERNINGRECORD(boolean fontFlagsWideCodes) throws IOException { + KERNINGRECORD ret = new KERNINGRECORD(); + if (fontFlagsWideCodes) { + ret.fontKerningCode1 = readUI16(); + ret.fontKerningCode2 = readUI16(); + } else { + ret.fontKerningCode1 = readUI8(); + ret.fontKerningCode2 = readUI8(); + } + ret.fontKerningAdjustment = readSI16(); + return ret; + } + + /** + * Reads one LANGCODE value from the stream + * + * @return LANGCODE value + * @throws IOException + */ + public LANGCODE readLANGCODE() throws IOException { + LANGCODE ret = new LANGCODE(); + ret.languageCode = readUI8(); + return ret; + } + + /** + * Reads one ZONERECORD value from the stream + * + * @return ZONERECORD value + * @throws IOException + */ + public ZONERECORD readZONERECORD() throws IOException { + ZONERECORD ret = new ZONERECORD(); + int numZoneData = readUI8(); + ret.zonedata = new ZONEDATA[numZoneData]; + for (int i = 0; i < numZoneData; i++) { + ret.zonedata[i] = readZONEDATA(); + } + readUB(6); + ret.zoneMaskX = readUB(1) == 1; + ret.zoneMaskY = readUB(1) == 1; + return ret; + } + + /** + * Reads one ZONEDATA value from the stream + * + * @return ZONEDATA value + * @throws IOException + */ + public ZONEDATA readZONEDATA() throws IOException { + ZONEDATA ret = new ZONEDATA(); + ret.alignmentCoordinate = readFLOAT16(); + ret.range = readFLOAT16(); return ret; } diff --git a/trunk/src/com/jpexs/asdec/SWFOutputStream.java b/trunk/src/com/jpexs/asdec/SWFOutputStream.java index 7b61eb437..13579e7e1 100644 --- a/trunk/src/com/jpexs/asdec/SWFOutputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFOutputStream.java @@ -19,6 +19,11 @@ package com.jpexs.asdec; import com.jpexs.asdec.tags.Tag; import com.jpexs.asdec.types.*; import com.jpexs.asdec.types.filters.*; +import com.jpexs.asdec.types.shaperecords.CurvedEdgeRecord; +import com.jpexs.asdec.types.shaperecords.EndShapeRecord; +import com.jpexs.asdec.types.shaperecords.SHAPERECORD; +import com.jpexs.asdec.types.shaperecords.StraightEdgeRecord; +import com.jpexs.asdec.types.shaperecords.StyleChangeRecord; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -329,6 +334,7 @@ public class SWFOutputStream extends OutputStream { writeSB(nBits, value.Xmax); writeSB(nBits, value.Ymin); writeSB(nBits, value.Ymax); + alignByte(); } /** @@ -1011,20 +1017,20 @@ public class SWFOutputStream extends OutputStream { * @param value FILLSTYLEARRAY value * @throws IOException */ - public void writeFILLSTYLEARRAY(FILLSTYLEARRAY value,int shapeNum) throws IOException { - int fillStyleCount=value.fillStyles.length; - if(shapeNum==2||shapeNum==3){ - if(fillStyleCount>=0xff){ + public void writeFILLSTYLEARRAY(FILLSTYLEARRAY value, int shapeNum) throws IOException { + int fillStyleCount = value.fillStyles.length; + if (shapeNum == 2 || shapeNum == 3) { + if (fillStyleCount >= 0xff) { writeUI8(0xff); writeUI16(fillStyleCount); - }else{ + } else { writeUI8(fillStyleCount); } - }else{ + } else { writeUI8(fillStyleCount); } for (int i = 0; i < value.fillStyles.length; i++) { - writeFILLSTYLE(value.fillStyles[i], shapeNum); + writeFILLSTYLE(value.fillStyles[i], shapeNum); } } @@ -1095,7 +1101,7 @@ public class SWFOutputStream extends OutputStream { * @param value LINESTYLE2 value * @throws IOException */ - public void writeLINESTYLE2(LINESTYLE2 value,int shapeNum) throws IOException { + public void writeLINESTYLE2(LINESTYLE2 value, int shapeNum) throws IOException { writeUI16(value.width); writeUB(2, value.startCapStyle); writeUB(2, value.joinStyle); @@ -1112,7 +1118,7 @@ public class SWFOutputStream extends OutputStream { if (!value.hasFillFlag) { writeRGBA(value.color); } else { - writeFILLSTYLE(value.fillType,shapeNum); + writeFILLSTYLE(value.fillType, shapeNum); } } @@ -1144,8 +1150,402 @@ public class SWFOutputStream extends OutputStream { writeUI8(lineStyleCount); } for (int i = 0; i < lineStyleCount; i++) { - writeLINESTYLE2(value.lineStyles2[i],shapeNum); + writeLINESTYLE2(value.lineStyles2[i], shapeNum); } } } + + /** + * Writes SHAPE value to the stream + * + * @param value SHAPE value + * @throws IOException + */ + public void writeSHAPE(SHAPE value, int shapeNum) throws IOException { + writeUB(4, value.numFillBits); + writeUB(4, value.numLineBits); + writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); + } + + /** + * Writes SHAPEWITHSTYLE value to the stream + * + * @param value SHAPEWITHSTYLE value + * @throws IOException + */ + public void writeSHAPEWITHSTYLE(SHAPEWITHSTYLE value, int shapeNum) throws IOException { + writeFILLSTYLEARRAY(value.fillStyles, shapeNum); + writeLINESTYLEARRAY(value.lineStyles, shapeNum); + writeUB(4, value.numFillBits); + writeUB(4, value.numLineBits); + writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); + } + + /** + * Writes SHAPERECORDs value to the stream + * + * @param value SHAPERECORDS value + * @throws IOException + */ + public void writeSHAPERECORDS(List value, int fillBits, int lineBits, int shapeNum) throws IOException { + for (SHAPERECORD sh : value) { + if (sh instanceof CurvedEdgeRecord) { + CurvedEdgeRecord cer = (CurvedEdgeRecord) sh; + writeUB(1, 1); //typeFlag + writeUB(1, 0);//curvedEdge + writeUB(4, cer.numBits); + writeUB(cer.numBits + 2, cer.controlDeltaX); + writeUB(cer.numBits + 2, cer.controlDeltaY); + writeUB(cer.numBits + 2, cer.anchorDeltaX); + writeUB(cer.numBits + 2, cer.anchorDeltaY); + } else if (sh instanceof StraightEdgeRecord) { + StraightEdgeRecord ser = (StraightEdgeRecord) sh; + writeUB(1, 1); //typeFlag + writeUB(1, 1);//straightEdge + writeUB(4, ser.numBits); + writeUB(1, ser.generalLineFlag ? 1 : 0); + if (!ser.generalLineFlag) { + writeUB(1, ser.vertLineFlag ? 1 : 0); + } + if (ser.generalLineFlag || (!ser.vertLineFlag)) { + writeSB(ser.numBits + 2, ser.deltaX); + } + if (ser.generalLineFlag || ser.vertLineFlag) { + writeSB(ser.numBits + 2, ser.deltaY); + } + } else if (sh instanceof StyleChangeRecord) { + StyleChangeRecord scr = (StyleChangeRecord) sh; + writeUB(1, 0); //typeFlag + writeUB(1, scr.stateNewStyles ? 1 : 0); + writeUB(1, scr.stateLineStyle ? 1 : 0); + writeUB(1, scr.stateFillStyle1 ? 1 : 0); + writeUB(1, scr.stateFillStyle0 ? 1 : 0); + writeUB(1, scr.stateMoveTo ? 1 : 0); + if (scr.stateMoveTo) { + writeUB(5, scr.moveBits); + writeUB(scr.moveBits, scr.moveDeltaX); + writeUB(scr.moveBits, scr.moveDeltaY); + } + if (scr.stateFillStyle0) { + writeUB(fillBits, scr.fillStyle0); + } + if (scr.stateFillStyle1) { + writeUB(fillBits, scr.fillStyle1); + } + if (scr.stateLineStyle) { + writeUB(lineBits, scr.lineStyle); + } + if (scr.stateNewStyles) { + writeFILLSTYLEARRAY(scr.fillStyles, shapeNum); + writeLINESTYLEARRAY(scr.lineStyles, shapeNum); + writeUB(4, scr.numFillBits); + writeUB(4, scr.numLineBits); + } + + } else if (sh instanceof EndShapeRecord) { + writeUB(1, 0); //typeFlag + writeUB(5, 0); //end of shape flag + } + } + alignByte(); + } + + /** + * Writes SOUNDINFO value to the stream + * + * @param value SOUNDINFO value + * @throws IOException + */ + public void writeSOUNDINFO(SOUNDINFO value) throws IOException { + writeUB(2, 0);//reserved + writeUB(1, value.syncStop ? 1 : 0); + writeUB(1, value.syncNoMultiple ? 1 : 0); + writeUB(1, value.hasEnvelope ? 1 : 0); + writeUB(1, value.hasLoops ? 1 : 0); + writeUB(1, value.hasOutPoint ? 1 : 0); + writeUB(1, value.hasInPoint ? 1 : 0); + if (value.hasInPoint) { + writeUI32(value.inPoint); + } + if (value.hasOutPoint) { + writeUI32(value.outPoint); + } + if (value.hasLoops) { + writeUI16(value.loopCount); + } + if (value.hasEnvelope) { + writeUI8(value.envelopeRecords.length); + for (SOUNDENVELOPE env : value.envelopeRecords) { + writeSOUNDENVELOPE(env); + } + } + } + + /** + * Writes SOUNDENVELOPE value to the stream + * + * @param value SOUNDENVELOPE value + * @throws IOException + */ + public void writeSOUNDENVELOPE(SOUNDENVELOPE value) throws IOException { + writeUI32(value.pos44); + writeUI16(value.leftLevel); + writeUI16(value.rightLevel); + } + + /** + * Writes TEXTRECORD value to the stream + * + * @param value TEXTRECORD value + * @throws IOException + */ + public void writeTEXTRECORD(TEXTRECORD value, boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { + writeUB(1, 1); + writeUB(3, 0); + writeUB(1, value.styleFlagsHasFont ? 1 : 0); + writeUB(1, value.styleFlagsHasColor ? 1 : 0); + writeUB(1, value.styleFlagsHasYOffset ? 1 : 0); + writeUB(1, value.styleFlagsHasXOffset ? 1 : 0); + if (value.styleFlagsHasFont) { + writeUI16(value.fontId); + } + if (value.styleFlagsHasColor) { + if (inDefineText2) { + writeRGBA(value.textColorA); + } else { + writeRGB(value.textColor); + } + } + if (value.styleFlagsHasXOffset) { + writeSI16(value.xOffset); + } + if (value.styleFlagsHasYOffset) { + writeSI16(value.yOffset); + } + if (value.styleFlagsHasFont) { + writeUI16(value.textHeight); + } + writeUI8(value.glyphEntries.length); + for (GLYPHENTRY ge : value.glyphEntries) { + writeGLYPHENTRY(ge, glyphBits, advanceBits); + } + } + + /** + * Writes GLYPHENTRY value to the stream + * + * @param value GLYPHENTRY value + * @throws IOException + */ + public void writeGLYPHENTRY(GLYPHENTRY value, int glyphBits, int advanceBits) throws IOException { + writeUB(glyphBits, value.glyphIndex); + writeSB(advanceBits, value.glyphAdvance); + } + + /** + * Writes MORPHFILLSTYLE value to the stream + * + * @param value MORPHFILLSTYLE value + * @throws IOException + */ + public void writeMORPHFILLSTYLE(MORPHFILLSTYLE value, int shapeNum) throws IOException { + writeUI8(value.fillStyleType); + if (value.fillStyleType == MORPHFILLSTYLE.SOLID) { + writeRGBA(value.startColor); + writeRGBA(value.endColor); + } + if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + writeMatrix(value.startGradientMatrix); + writeMatrix(value.endGradientMatrix); + } + if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + writeMORPHGRADIENT(value.gradient, shapeNum); + } + + if ((value.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + writeUI16(value.bitmapId); + writeMatrix(value.startBitmapMatrix); + writeMatrix(value.endBitmapMatrix); + } + } + + /** + * WritesMORPH FILLSTYLEARRAY value to the stream + * + * @param value MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public void writeMORPHFILLSTYLEARRAY(MORPHFILLSTYLEARRAY value, int morphShapeNum) throws IOException { + int fillStyleCount = value.fillStyles.length; + if (fillStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(fillStyleCount); + } else { + writeUI8(fillStyleCount); + } + for (int i = 0; i < value.fillStyles.length; i++) { + writeMORPHFILLSTYLE(value.fillStyles[i], morphShapeNum); + } + } + + /** + * Writes MORPHGRADIENT value to the stream + * + * @param value MORPHGRADIENT value + * @throws IOException + */ + public void writeMORPHGRADIENT(MORPHGRADIENT value, int shapeNum) throws IOException { + writeUB(4, value.gradientRecords.length); + for (int i = 0; i < value.gradientRecords.length; i++) { + writeMORPHGRADRECORD(value.gradientRecords[i]); + } + } + + /** + * Writes MORPHGRADRECORD value to the stream + * + * @param value MORPHGRADRECORD value + * @throws IOException + */ + public void writeMORPHGRADRECORD(MORPHGRADRECORD value) throws IOException { + writeUI8(value.startRatio); + writeRGBA(value.startColor); + writeUI8(value.endRatio); + writeRGBA(value.endColor); + } + + /** + * Writes MORPHLINESTYLE value to the stream + * + * @param value LINESTYLE value + * @throws IOException + */ + public void writeMORPHLINESTYLE(MORPHLINESTYLE value, int shapeNum) throws IOException { + writeUI16(value.startWidth); + writeUI16(value.endWidth); + writeRGBA(value.startColor); + writeRGBA(value.endColor); + + } + + /** + * Writes MORPHLINESTYLE2 value to the stream + * + * @param value MORPHLINESTYLE2 value + * @throws IOException + */ + public void writeMORPHLINESTYLE2(MORPHLINESTYLE2 value, int shapeNum) throws IOException { + writeUI16(value.startWidth); + writeUI16(value.endWidth); + writeUB(2, value.startCapStyle); + writeUB(2, value.joinStyle); + writeUB(1, value.hasFillFlag ? 1 : 0); + writeUB(1, value.noHScaleFlag ? 1 : 0); + writeUB(1, value.noVScaleFlag ? 1 : 0); + writeUB(1, value.pixelHintingFlag ? 1 : 0); + writeUB(5, 0);//reserved + writeUB(1, value.noClose ? 1 : 0); + writeUB(2, value.endCapStyle); + if (value.joinStyle == LINESTYLE2.MITER_JOIN) { + writeUI16(value.miterLimitFactor); + } + if (!value.hasFillFlag) { + writeRGBA(value.startColor); + writeRGBA(value.endColor); + } else { + writeMORPHFILLSTYLE(value.fillType, shapeNum); + } + } + + /** + * Writes MORPHLINESTYLEARRAY value to the stream + * + * @param value MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public void writeMORPHLINESTYLEARRAY(MORPHLINESTYLEARRAY value, int morphShapeNum) throws IOException { + int lineStyleCount; + if (morphShapeNum == 1) { + lineStyleCount = value.lineStyles.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); + } + for (int i = 0; i < lineStyleCount; i++) { + writeMORPHLINESTYLE(value.lineStyles[i], morphShapeNum); + } + } else if (morphShapeNum == 2) { + lineStyleCount = value.lineStyles2.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); + } + for (int i = 0; i < lineStyleCount; i++) { + writeMORPHLINESTYLE2(value.lineStyles2[i], morphShapeNum); + } + } + } + + /** + * Writes KERNINGRECORD value to the stream + * + * @param value KERNINGRECORD value + * @throws IOException + */ + public void writeKERNINGRECORD(KERNINGRECORD value, boolean fontFlagsWideCodes) throws IOException { + if (fontFlagsWideCodes) { + writeUI16(value.fontKerningCode1); + writeUI16(value.fontKerningCode2); + } else { + writeUI8(value.fontKerningCode1); + writeUI8(value.fontKerningCode2); + } + writeSI16(value.fontKerningAdjustment); + } + + /** + * Writes LANGCODE value to the stream + * + * @param value LANGCODE value + * @throws IOException + */ + public void writeLANGCODE(LANGCODE value) throws IOException { + writeUI8(value.languageCode); + } + + /** + * Writes ZONERECORD value to the stream + * + * @param value ZONERECORD value + * @throws IOException + */ + public void writeZONERECORD(ZONERECORD value) throws IOException { + writeUI8(value.zonedata.length); + for (int i = 0; i < value.zonedata.length; i++) { + writeZONEDATA(value.zonedata[i]); + } + writeUB(6, 0); + writeUB(1, value.zoneMaskX ? 1 : 0); + writeUB(1, value.zoneMaskY ? 1 : 0); + } + + /** + * Writes ZONEDATA value to the stream + * + * @param value ZONEDATA value + * @throws IOException + */ + public void writeZONEDATA(ZONEDATA value) throws IOException { + writeFLOAT16(value.alignmentCoordinate); + writeFLOAT16(value.range); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/CopyOutputStream.java b/trunk/src/com/jpexs/asdec/abc/CopyOutputStream.java index 822540678..6bef8c2fe 100644 --- a/trunk/src/com/jpexs/asdec/abc/CopyOutputStream.java +++ b/trunk/src/com/jpexs/asdec/abc/CopyOutputStream.java @@ -28,6 +28,7 @@ public class CopyOutputStream extends OutputStream { private int TEMPSIZE = 5; private int temp[] = new int[TEMPSIZE]; private int tempPos = 0; + public int ignoreFirst = 0; public CopyOutputStream(OutputStream os, InputStream is) { this.os = os; @@ -42,25 +43,29 @@ public class CopyOutputStream extends OutputStream { pos++; int r = is.read(); if ((b & 0xff) != r) { - os.flush(); + if (ignoreFirst <= 0) { + os.flush(); - boolean output = false; + boolean output = true; - if (output) { - System.out.print("Last written:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); + if (output) { + System.out.print("Last written:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); + } + System.out.println(""); + System.out.println("More expected:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.println("" + Integer.toHexString(is.read())); + } + + System.out.println(""); + System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); } - System.out.println(""); - System.out.println("More expected:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.println("" + Integer.toHexString(is.read())); - } - - System.out.println(""); - System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); + throw new NotSameException(pos); + } else { + ignoreFirst--; } - throw new NotSameException(pos); } os.write(b); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java index b8824c775..a4c985e69 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java @@ -63,7 +63,7 @@ public class ConstructIns extends InstructionDefinition { } else if (item instanceof AddTreeItem) { ret = ret && walkXML(((AddTreeItem) item).leftSide, list); ret = ret && walkXML(((AddTreeItem) item).rightSide, list); - } else if ((item instanceof EscapeXElemTreeItem)||(item instanceof EscapeXAttrTreeItem)) { + } else if ((item instanceof EscapeXElemTreeItem) || (item instanceof EscapeXAttrTreeItem)) { list.add(item); } else { return false; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java index aa4dbe9b9..94a3d642f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java @@ -22,9 +22,7 @@ import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import com.jpexs.asdec.abc.avm2.treemodel.DefaultXMLNamespace; -import com.jpexs.asdec.abc.avm2.treemodel.StringTreeItem; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; -import com.jpexs.asdec.abc.avm2.treemodel.UnparsedTreeItem; import com.jpexs.asdec.abc.types.MethodInfo; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java index 71850cb59..1b6f024e7 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java @@ -23,7 +23,6 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import com.jpexs.asdec.abc.avm2.treemodel.EscapeXAttrTreeItem; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; -import com.jpexs.asdec.abc.avm2.treemodel.UnparsedTreeItem; import com.jpexs.asdec.abc.types.MethodInfo; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DefaultXMLNamespace.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DefaultXMLNamespace.java index 522403359..48cd73b56 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DefaultXMLNamespace.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DefaultXMLNamespace.java @@ -13,19 +13,17 @@ import java.util.List; * * @author Jindra */ -public class DefaultXMLNamespace extends TreeItem{ +public class DefaultXMLNamespace extends TreeItem { private TreeItem ns; - public DefaultXMLNamespace(AVM2Instruction instruction,TreeItem ns) { + + public DefaultXMLNamespace(AVM2Instruction instruction, TreeItem ns) { super(instruction, NOPRECEDENCE); - this.ns=ns; + this.ns = ns; } - - @Override public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("default xml namespace = ")+ns.toString(constants, localRegNames, fullyQualifiedNames); + return hilight("default xml namespace = ") + ns.toString(constants, localRegNames, fullyQualifiedNames); } - } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java b/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java index 05e8c0089..ec8b74809 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java @@ -37,8 +37,6 @@ import javax.swing.border.BevelBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.table.*; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; import jsyntaxpane.DefaultSyntaxKit; public class MainFrame extends JFrame implements ActionListener, ItemListener { diff --git a/trunk/src/com/jpexs/asdec/action/TagNode.java b/trunk/src/com/jpexs/asdec/action/TagNode.java index 34ccc8479..455ea769d 100644 --- a/trunk/src/com/jpexs/asdec/action/TagNode.java +++ b/trunk/src/com/jpexs/asdec/action/TagNode.java @@ -16,14 +16,14 @@ */ package com.jpexs.asdec.action; -import com.jpexs.asdec.tags.base.ASMSource; -import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.tags.DefineButton2Tag; import com.jpexs.asdec.tags.DefineButtonTag; import com.jpexs.asdec.tags.DefineSpriteTag; import com.jpexs.asdec.tags.DoInitActionTag; import com.jpexs.asdec.tags.ExportAssetsTag; import com.jpexs.asdec.tags.ShowFrameTag; +import com.jpexs.asdec.tags.base.ASMSource; +import com.jpexs.asdec.tags.base.Container; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java index d45e31fba..9a9cc1ebc 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java +++ b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java @@ -25,8 +25,8 @@ import com.jpexs.asdec.action.parser.ParseException; import com.jpexs.asdec.gui.LoadingPanel; import com.jpexs.asdec.gui.View; import com.jpexs.asdec.helpers.Highlighting; -import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.tags.Tag; +import com.jpexs.asdec.tags.base.ASMSource; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; diff --git a/trunk/src/com/jpexs/asdec/tags/CSMTextSettingsTag.java b/trunk/src/com/jpexs/asdec/tags/CSMTextSettingsTag.java new file mode 100644 index 000000000..0d709964b --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/CSMTextSettingsTag.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class CSMTextSettingsTag extends Tag { + + public int textID; + public int useFlashType; + public int gridFit; + public double thickness; + public double sharpness; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(textID); + sos.writeUB(2, useFlashType); + sos.writeUB(3, gridFit); + sos.writeUB(3, 0); + sos.writeFIXED(thickness); //TODO:write F32 + sos.writeFIXED(sharpness); //TODO:write F32 + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public CSMTextSettingsTag(byte data[], int version, long pos) throws IOException { + super(74, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + textID = sis.readUI16(); + useFlashType = (int) sis.readUB(2); + gridFit = (int) sis.readUB(3); + sis.readUB(3); //reserved + thickness = sis.readFIXED(); //TODO: read F32 + sharpness = sis.readFIXED(); //TODO: read F32 + sis.readUI8(); //reserved + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "CSMTextSettings"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DebugIDTag.java b/trunk/src/com/jpexs/asdec/tags/DebugIDTag.java index a4c1786f8..04bb760d1 100644 --- a/trunk/src/com/jpexs/asdec/tags/DebugIDTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DebugIDTag.java @@ -22,8 +22,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; /** * diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBinaryDataTag.java b/trunk/src/com/jpexs/asdec/tags/DefineBinaryDataTag.java index dbb43ff47..fe6e1f6db 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBinaryDataTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBinaryDataTag.java @@ -16,11 +16,42 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineBinaryDataTag extends Tag { - public DefineBinaryDataTag(byte[] data, int version, long pos) { + public int tag; + public byte binaryData[]; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(tag); + sos.write(binaryData); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + public DefineBinaryDataTag(byte[] data, int version, long pos) throws IOException { super(87, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + tag = sis.readUI16(); + binaryData = sis.readBytes(sis.available()); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java index d3fe9dcb8..cf028b2fb 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java @@ -16,11 +16,20 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; + public class DefineBitsJPEG2Tag extends Tag { - public DefineBitsJPEG2Tag(byte[] data, int version, long pos) { + public int characterId; + public byte[] imageData; + + public DefineBitsJPEG2Tag(byte[] data, int version, long pos) throws IOException { super(21, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterId = sis.readUI16(); + imageData = sis.readBytes(sis.available()); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG3Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG3Tag.java index 5dce6b58c..80b6c5145 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG3Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG3Tag.java @@ -16,11 +16,47 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineBitsJPEG3Tag extends Tag { - public DefineBitsJPEG3Tag(byte[] data, int version, long pos) { + public int characterID; + public byte imageData[]; + public byte bitmapAlphaData[]; + + public DefineBitsJPEG3Tag(byte[] data, int version, long pos) throws IOException { super(35, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + long alphaDataOffset = sis.readUI32(); + imageData = sis.readBytes(alphaDataOffset); + bitmapAlphaData = sis.readBytes(sis.available()); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.writeUI32(imageData.length); + sos.write(imageData); + sos.write(bitmapAlphaData); + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG4Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG4Tag.java new file mode 100644 index 000000000..e29360ed8 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG4Tag.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineBitsJPEG4Tag extends Tag { + + public int characterID; + public int deblockParam; + public byte imageData[]; + public byte bitmapAlphaData[]; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.writeUI32(imageData.length); + sos.writeUI16(deblockParam); + sos.write(imageData); + sos.write(bitmapAlphaData); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineBitsJPEG4Tag(byte data[], int version, long pos) throws IOException { + super(90, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + long alphaDataOffset = sis.readUI32(); + deblockParam = sis.readUI16(); + imageData = sis.readBytes(alphaDataOffset); + bitmapAlphaData = sis.readBytes(sis.available()); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineBitsJPEG4"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsLossless2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsLossless2Tag.java index 6cc53c478..5a0e81050 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsLossless2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsLossless2Tag.java @@ -16,13 +16,61 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; public class DefineBitsLossless2Tag extends Tag { + public int characterID; + public int bitmapFormat; + public int bitmapWidth; + public int bitmapHeight; + public int bitmapColorTableSize; + public byte zlibBitmapData[]; //TODO: Parse ALPHACOLORMAPDATA,ALPHABITMAPDATA + public static final int FORMAT_8BIT_COLORMAPPED = 3; + public static final int FORMAT_15BIT_RGB = 4; + public static final int FORMAT_24BIT_RGB = 5; + public DefineBitsLossless2Tag(byte[] data, int version, long pos) throws IOException { super(36, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + bitmapFormat = sis.readUI8(); + bitmapWidth = sis.readUI16(); + bitmapHeight = sis.readUI16(); + if (bitmapFormat == FORMAT_15BIT_RGB) { + bitmapColorTableSize = sis.readUI8(); + } + zlibBitmapData = sis.readBytes(sis.available()); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.writeUI8(bitmapFormat); + sos.writeUI16(bitmapWidth); + sos.writeUI16(bitmapHeight); + if (bitmapFormat == FORMAT_15BIT_RGB) { + sos.writeUI8(bitmapColorTableSize); + } + sos.write(zlibBitmapData); + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsLosslessTag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsLosslessTag.java index 38e100f53..b300b10cb 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsLosslessTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsLosslessTag.java @@ -16,11 +16,61 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineBitsLosslessTag extends Tag { - public DefineBitsLosslessTag(byte[] data, int version, long pos) { + public int characterID; + public int bitmapFormat; + public int bitmapWidth; + public int bitmapHeight; + public int bitmapColorTableSize; + public byte zlibBitmapData[]; //TODO: Parse COLORMAPDATA,BITMAPDATA + public static final int FORMAT_8BIT_COLORMAPPED = 3; + public static final int FORMAT_15BIT_RGB = 4; + public static final int FORMAT_24BIT_RGB = 5; + + public DefineBitsLosslessTag(byte[] data, int version, long pos) throws IOException { super(20, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + bitmapFormat = sis.readUI8(); + bitmapWidth = sis.readUI16(); + bitmapHeight = sis.readUI16(); + if (bitmapFormat == FORMAT_15BIT_RGB) { + bitmapColorTableSize = sis.readUI8(); + } + zlibBitmapData = sis.readBytes(sis.available()); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.writeUI8(bitmapFormat); + sos.writeUI16(bitmapWidth); + sos.writeUI16(bitmapHeight); + if (bitmapFormat == FORMAT_15BIT_RGB) { + sos.writeUI8(bitmapColorTableSize); + } + sos.write(zlibBitmapData); + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsTag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsTag.java index e2284feec..165dc6bf3 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsTag.java @@ -16,11 +16,42 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineBitsTag extends Tag { - public DefineBitsTag(byte[] data, int version, long pos) { + public int characterID; + public byte jpegData[]; + + public DefineBitsTag(byte[] data, int version, long pos) throws IOException { super(6, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + jpegData = sis.readBytes(sis.available()); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.write(jpegData); + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java index 23fbd6d67..8a64c6dfd 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java @@ -16,12 +16,12 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.TagName; -import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.Main; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.abc.CopyOutputStream; +import com.jpexs.asdec.tags.base.Container; +import com.jpexs.asdec.tags.base.TagName; import com.jpexs.asdec.types.BUTTONCONDACTION; import com.jpexs.asdec.types.BUTTONRECORD; import java.io.ByteArrayInputStream; diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButtonCxform.java b/trunk/src/com/jpexs/asdec/tags/DefineButtonCxform.java new file mode 100644 index 000000000..ef85bc5cc --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineButtonCxform.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.CXFORM; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineButtonCxform extends Tag { + + public int buttonId; + public CXFORM buttonColorTransform; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(buttonId); + sos.writeCXFORM(buttonColorTransform); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineButtonCxform(byte data[], int version, long pos) throws IOException { + super(23, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + buttonId = sis.readUI16(); + buttonColorTransform = sis.readCXFORM(); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineButtonCxform"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButtonSoundTag.java b/trunk/src/com/jpexs/asdec/tags/DefineButtonSoundTag.java new file mode 100644 index 000000000..4c3bdc094 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineButtonSoundTag.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.SOUNDINFO; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineButtonSoundTag extends Tag { + + public int buttonId; + public int buttonSoundChar0; + public SOUNDINFO buttonSoundInfo0; + public int buttonSoundChar1; + public SOUNDINFO buttonSoundInfo1; + public int buttonSoundChar2; + public SOUNDINFO buttonSoundInfo2; + public int buttonSoundChar3; + public SOUNDINFO buttonSoundInfo3; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(buttonId); + sos.writeUI16(buttonSoundChar0); + if (buttonSoundChar0 != 0) { + sos.writeSOUNDINFO(buttonSoundInfo0); + } + sos.writeUI16(buttonSoundChar1); + if (buttonSoundChar1 != 0) { + sos.writeSOUNDINFO(buttonSoundInfo1); + } + sos.writeUI16(buttonSoundChar2); + if (buttonSoundChar2 != 0) { + sos.writeSOUNDINFO(buttonSoundInfo2); + } + sos.writeUI16(buttonSoundChar3); + if (buttonSoundChar3 != 0) { + sos.writeSOUNDINFO(buttonSoundInfo3); + } + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineButtonSoundTag(byte data[], int version, long pos) throws IOException { + super(17, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + buttonId = sis.readUI16(); + buttonSoundChar0 = sis.readUI16(); + if (buttonSoundChar0 != 0) { + buttonSoundInfo0 = sis.readSOUNDINFO(); + } + buttonSoundChar1 = sis.readUI16(); + if (buttonSoundChar1 != 0) { + buttonSoundInfo1 = sis.readSOUNDINFO(); + } + buttonSoundChar2 = sis.readUI16(); + if (buttonSoundChar2 != 0) { + buttonSoundInfo2 = sis.readSOUNDINFO(); + } + buttonSoundChar3 = sis.readUI16(); + if (buttonSoundChar3 != 0) { + buttonSoundInfo3 = sis.readSOUNDINFO(); + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineButtonSound"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java index b212e9763..2001fd393 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java @@ -16,13 +16,13 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.TagName; -import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.Main; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.abc.CopyOutputStream; import com.jpexs.asdec.action.Action; +import com.jpexs.asdec.tags.base.ASMSource; +import com.jpexs.asdec.tags.base.TagName; import com.jpexs.asdec.types.BUTTONRECORD; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/trunk/src/com/jpexs/asdec/tags/DefineEditTextTag.java b/trunk/src/com/jpexs/asdec/tags/DefineEditTextTag.java new file mode 100644 index 000000000..dc7cf4106 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineEditTextTag.java @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.RGBA; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineEditTextTag extends Tag { + + public int characterId; + public RECT bounds; + public boolean hasText; + public boolean wordWrap; + public boolean multiline; + public boolean password; + public boolean readOnly; + public boolean hasTextColor; + public boolean hasMaxLength; + public boolean hasFont; + public boolean hasFontClass; + public boolean autoSize; + public boolean hasLayout; + public boolean noSelect; + public boolean border; + public boolean wasStatic; + public boolean html; + public boolean useOutlines; + public int fontId; + public String fontClass; + public int fontHeight; + public RGBA textColor; + public int maxLength; + public int align; + public int leftMargin; + public int rightMargin; + public int indent; + public int leading; + public String variableName; + public String initialText; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterId); + sos.writeRECT(bounds); + sos.writeUB(1, hasText ? 1 : 0); + sos.writeUB(1, wordWrap ? 1 : 0); + sos.writeUB(1, multiline ? 1 : 0); + sos.writeUB(1, password ? 1 : 0); + sos.writeUB(1, readOnly ? 1 : 0); + sos.writeUB(1, hasTextColor ? 1 : 0); + sos.writeUB(1, hasMaxLength ? 1 : 0); + sos.writeUB(1, hasFont ? 1 : 0); + sos.writeUB(1, hasFontClass ? 1 : 0); + sos.writeUB(1, autoSize ? 1 : 0); + sos.writeUB(1, hasLayout ? 1 : 0); + sos.writeUB(1, noSelect ? 1 : 0); + sos.writeUB(1, border ? 1 : 0); + sos.writeUB(1, wasStatic ? 1 : 0); + sos.writeUB(1, html ? 1 : 0); + sos.writeUB(1, useOutlines ? 1 : 0); + if (hasFont) { + sos.writeUI16(fontId); + } + if (hasFontClass) { + sos.writeString(fontClass); + } + if (hasFont) { + sos.writeUI16(fontHeight); + } + if (hasTextColor) { + sos.writeRGBA(textColor); + } + if (hasMaxLength) { + sos.writeUI16(maxLength); + } + if (hasLayout) { + sos.writeUI8(align); + sos.writeUI16(leftMargin); + sos.writeUI16(rightMargin); + sos.writeUI16(indent); + sos.writeSI16(leading); + } + sos.writeString(variableName); + if (hasText) { + sos.writeString(initialText); + } + + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineEditTextTag(byte data[], int version, long pos) throws IOException { + super(0, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterId = sis.readUI16(); + bounds = sis.readRECT(); + hasText = sis.readUB(1) == 1; + wordWrap = sis.readUB(1) == 1; + multiline = sis.readUB(1) == 1; + password = sis.readUB(1) == 1; + readOnly = sis.readUB(1) == 1; + hasTextColor = sis.readUB(1) == 1; + hasMaxLength = sis.readUB(1) == 1; + hasFont = sis.readUB(1) == 1; + hasFontClass = sis.readUB(1) == 1; + autoSize = sis.readUB(1) == 1; + hasLayout = sis.readUB(1) == 1; + noSelect = sis.readUB(1) == 1; + border = sis.readUB(1) == 1; + wasStatic = sis.readUB(1) == 1; + html = sis.readUB(1) == 1; + useOutlines = sis.readUB(1) == 1; + if (hasFont) { + fontId = sis.readUI16(); + } + if (hasFontClass) { + fontClass = sis.readString(); + } + if (hasFont) { + fontHeight = sis.readUI16(); + } + if (hasTextColor) { + textColor = sis.readRGBA(); + } + if (hasMaxLength) { + maxLength = sis.readUI16(); + } + if (hasLayout) { + align = sis.readUI8(); //0 left,1 right, 2 center, 3 justify + leftMargin = sis.readUI16(); + rightMargin = sis.readUI16(); + indent = sis.readUI16(); + leading = sis.readSI16(); + } + variableName = sis.readString(); + if (hasText) { + initialText = sis.readString(); + } + + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineEditText"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFont2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineFont2Tag.java new file mode 100644 index 000000000..7ed9934be --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineFont2Tag.java @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.abc.CopyOutputStream; +import com.jpexs.asdec.types.KERNINGRECORD; +import com.jpexs.asdec.types.LANGCODE; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.SHAPE; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineFont2Tag extends Tag { + + public int fontId; + public boolean fontFlagsHasLayout; + public boolean fontFlagsShiftJIS; + public boolean fontFlagsSmallText; + public boolean fontFlagsANSI; + public boolean fontFlagsWideOffsets; + public boolean fontFlagsWideCodes; + public boolean fontFlagsItalic; + public boolean fontFlagsBold; + public LANGCODE languageCode; + public String fontName; + public int numGlyphs; + public long offsetTable[]; + public SHAPE glyphShapeTable[]; + public int codeTable[]; + public int fontAscent; + public int fontDescent; + public int fontLeading; + public int fontAdvanceTable[]; + public RECT fontBoundsTable[]; + public KERNINGRECORD fontKerningTable[]; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = new CopyOutputStream(baos, new ByteArrayInputStream(data)); + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontId); + sos.writeUB(1, fontFlagsHasLayout ? 1 : 0); + sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0); + sos.writeUB(1, fontFlagsSmallText ? 1 : 0); + sos.writeUB(1, fontFlagsANSI ? 1 : 0); + sos.writeUB(1, fontFlagsWideOffsets ? 1 : 0); + sos.writeUB(1, fontFlagsWideCodes ? 1 : 0); + sos.writeUB(1, fontFlagsItalic ? 1 : 0); + sos.writeUB(1, fontFlagsBold ? 1 : 0); + sos.writeLANGCODE(languageCode); + sos.writeUI8(fontName.getBytes().length); + sos.write(fontName.getBytes()); + sos.writeUI16(numGlyphs); + + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideOffsets) { + sos2.writeUI32(offsetTable[i]); + } else { + sos2.writeUI16((int) offsetTable[i]); + } + } + byte ba2[] = baos2.toByteArray(); + ByteArrayOutputStream baos3 = new ByteArrayOutputStream(); + SWFOutputStream sos3 = new SWFOutputStream(baos3, version); + for (int i = 0; i < numGlyphs; i++) { + sos3.writeSHAPE(glyphShapeTable[i], 1); + } + byte ba3[] = baos3.toByteArray(); + sos.write(ba2); + long offset = ba2.length + ba3.length; + if (fontFlagsWideOffsets) { + sos.writeUI32(offset + 4); + } else { + sos.writeUI16((int) (offset + 2)); + } + sos.write(ba3); + + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideCodes) { + sos.writeUI16(codeTable[i]); + } else { + sos.writeUI8(codeTable[i]); + } + } + if (fontFlagsHasLayout) { + sos.writeSI16(fontAscent); + sos.writeSI16(fontDescent); + sos.writeSI16(fontLeading); + for (int i = 0; i < numGlyphs; i++) { + sos.writeSI16(fontAdvanceTable[i]); + } + for (int i = 0; i < numGlyphs; i++) { + sos.writeRECT(fontBoundsTable[i]); + } + sos.writeUI16(fontKerningTable.length); + for (int k = 0; k < fontKerningTable.length; k++) { + sos.writeKERNINGRECORD(fontKerningTable[k], fontFlagsWideCodes); + } + } + + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineFont2Tag(byte data[], int version, long pos) throws IOException { + super(48, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontId = sis.readUI16(); + fontFlagsHasLayout = sis.readUB(1) == 1; + fontFlagsShiftJIS = sis.readUB(1) == 1; + fontFlagsSmallText = sis.readUB(1) == 1; + fontFlagsANSI = sis.readUB(1) == 1; + fontFlagsWideOffsets = sis.readUB(1) == 1; + fontFlagsWideCodes = sis.readUB(1) == 1; + fontFlagsItalic = sis.readUB(1) == 1; + fontFlagsBold = sis.readUB(1) == 1; + languageCode = sis.readLANGCODE(); + int fontNameLen = sis.readUI8(); + fontName = new String(sis.readBytes(fontNameLen)); + numGlyphs = sis.readUI16(); + offsetTable = new long[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideOffsets) { + offsetTable[i] = sis.readUI32(); + } else { + offsetTable[i] = sis.readUI16(); + } + } + long codeTableOffset; + if (fontFlagsWideOffsets) { + codeTableOffset = sis.readUI32(); + } else { + codeTableOffset = sis.readUI16(); + } + + glyphShapeTable = new SHAPE[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + glyphShapeTable[i] = sis.readSHAPE(1); + } + + codeTable = new int[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideCodes) { + codeTable[i] = sis.readUI16(); + } else { + codeTable[i] = sis.readUI8(); + } + } + if (fontFlagsHasLayout) { + fontAscent = sis.readSI16(); + fontDescent = sis.readSI16(); + fontLeading = sis.readSI16(); + fontAdvanceTable = new int[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + fontAdvanceTable[i] = sis.readSI16(); + } + fontBoundsTable = new RECT[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + fontBoundsTable[i] = sis.readRECT(); + } + int kerningCount = sis.readUI16(); + fontKerningTable = new KERNINGRECORD[kerningCount]; + for (int i = 0; i < kerningCount; i++) { + fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes); + } + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineFont2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java index 063759f97..12a3c3923 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java @@ -16,11 +16,171 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.KERNINGRECORD; +import com.jpexs.asdec.types.LANGCODE; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.SHAPE; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineFont3Tag extends Tag { - public DefineFont3Tag(byte[] data, int version, long pos) { + public int fontId; + public boolean fontFlagsHasLayout; + public boolean fontFlagsShiftJIS; + public boolean fontFlagsSmallText; + public boolean fontFlagsANSI; + public boolean fontFlagsWideOffsets; + public boolean fontFlagsWideCodes; + public boolean fontFlagsItalic; + public boolean fontFlagsBold; + public LANGCODE languageCode; + public String fontName; + public int numGlyphs; + public long offsetTable[]; + public SHAPE glyphShapeTable[]; + public int codeTable[]; + public int fontAscent; + public int fontDescent; + public int fontLeading; + public int fontAdvanceTable[]; + public RECT fontBoundsTable[]; + public KERNINGRECORD fontKerningTable[]; + + public DefineFont3Tag(byte[] data, int version, long pos) throws IOException { super(75, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontId = sis.readUI16(); + fontFlagsHasLayout = sis.readUB(1) == 1; + fontFlagsShiftJIS = sis.readUB(1) == 1; + fontFlagsSmallText = sis.readUB(1) == 1; + fontFlagsANSI = sis.readUB(1) == 1; + fontFlagsWideOffsets = sis.readUB(1) == 1; + fontFlagsWideCodes = sis.readUB(1) == 1; + fontFlagsItalic = sis.readUB(1) == 1; + fontFlagsBold = sis.readUB(1) == 1; + languageCode = sis.readLANGCODE(); + int fontNameLen = sis.readUI8(); + fontName = new String(sis.readBytes(fontNameLen)); + numGlyphs = sis.readUI16(); + offsetTable = new long[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideOffsets) { + offsetTable[i] = sis.readUI32(); + } else { + offsetTable[i] = sis.readUI16(); + } + } + long codeTableOffset = sis.readUI32(); + glyphShapeTable = new SHAPE[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + glyphShapeTable[i] = sis.readSHAPE(1); + } + + codeTable = new int[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideOffsets) { + codeTable[i] = sis.readUI16(); + } else { + codeTable[i] = sis.readUI8(); + } + } + if (fontFlagsHasLayout) { + fontAscent = sis.readSI16(); + fontDescent = sis.readSI16(); + fontLeading = sis.readSI16(); + fontAdvanceTable = new int[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + fontAdvanceTable[i] = sis.readSI16(); + } + fontBoundsTable = new RECT[numGlyphs]; + for (int i = 0; i < numGlyphs; i++) { + fontBoundsTable[i] = sis.readRECT(); + } + int kerningCount = sis.readUI16(); + fontKerningTable = new KERNINGRECORD[kerningCount]; + for (int i = 0; i < kerningCount; i++) { + fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes); + } + } + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontId); + sos.writeUB(1, fontFlagsHasLayout ? 1 : 0); + sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0); + sos.writeUB(1, fontFlagsSmallText ? 1 : 0); + sos.writeUB(1, fontFlagsANSI ? 1 : 0); + sos.writeUB(1, fontFlagsWideOffsets ? 1 : 0); + sos.writeUB(1, fontFlagsWideCodes ? 1 : 0); + sos.writeUB(1, fontFlagsItalic ? 1 : 0); + sos.writeUB(1, fontFlagsBold ? 1 : 0); + sos.writeLANGCODE(languageCode); + sos.writeUI8(fontName.getBytes().length); + sos.write(fontName.getBytes()); + sos.write(numGlyphs); + + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideOffsets) { + sos2.writeUI32(offsetTable[i]); + } else { + sos2.writeUI16((int) offsetTable[i]); + } + } + byte ba2[] = baos2.toByteArray(); + ByteArrayOutputStream baos3 = new ByteArrayOutputStream(); + SWFOutputStream sos3 = new SWFOutputStream(baos2, version); + for (int i = 0; i < numGlyphs; i++) { + sos3.writeSHAPE(glyphShapeTable[i], 1); + } + byte ba3[] = baos3.toByteArray(); + sos.write(ba2); + sos.writeUI32(ba2.length + ba3.length + 4); + sos.write(ba3); + + for (int i = 0; i < numGlyphs; i++) { + if (fontFlagsWideCodes) { + sos.writeUI16(codeTable[i]); + } else { + sos.writeUI8(codeTable[i]); + } + } + if (fontFlagsHasLayout) { + sos.writeSI16(fontAscent); + sos.writeSI16(fontDescent); + sos.writeSI16(fontLeading); + for (int i = 0; i < numGlyphs; i++) { + sos.writeSI16(fontAdvanceTable[i]); + } + for (int i = 0; i < numGlyphs; i++) { + sos.writeRECT(fontBoundsTable[i]); + } + sos.writeUI16(fontKerningTable.length); + for (int k = 0; k < fontKerningTable.length; k++) { + sos.writeKERNINGRECORD(fontKerningTable[k], fontFlagsWideCodes); + } + } + + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFont4Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineFont4Tag.java index b898ccc78..b25eda76a 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFont4Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFont4Tag.java @@ -16,11 +16,56 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class DefineFont4Tag extends Tag { - public DefineFont4Tag(byte[] data, int version, long pos) { + public int fontID; + public boolean fontFlagsHasFontData; + public boolean fontFlagsItalic; + public boolean fontFlagsBold; + public String fontName; + public byte fontData[]; + + public DefineFont4Tag(byte[] data, int version, long pos) throws IOException { super(91, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontID = sis.readUI16(); + sis.readUB(5); + fontFlagsHasFontData = sis.readUB(1) == 1; + fontFlagsItalic = sis.readUB(1) == 1; + fontFlagsBold = sis.readUB(1) == 1; + fontName = sis.readString(); + fontData = sis.readBytes(sis.available()); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontID); + sos.writeUB(5, 0); + sos.writeUB(1, fontFlagsHasFontData ? 1 : 0); + sos.writeUB(1, fontFlagsItalic ? 1 : 0); + sos.writeUB(1, fontFlagsBold ? 1 : 0); + sos.writeString(fontName); + sos.write(fontData); + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java index d152d579e..e520928c1 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java @@ -16,11 +16,55 @@ */ package com.jpexs.asdec.tags; +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.ZONERECORD; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + public class DefineFontAlignZonesTag extends Tag { - public DefineFontAlignZonesTag(byte[] data, int version, long pos) { + public int fontID; + public int CSMTableHint; + public List zoneTable; + + public DefineFontAlignZonesTag(byte[] data, int version, long pos) throws IOException { super(73, data, pos); - // TODO Auto-generated constructor stub + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontID = sis.readUI16(); + CSMTableHint = (int) sis.readUB(2); + sis.readUB(6); + zoneTable = new ArrayList(); + while (sis.available() > 0) { + zoneTable.add(sis.readZONERECORD()); + } + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontID); + sos.writeUB(2, CSMTableHint); + sos.writeUB(6, 0); + for (ZONERECORD z : zoneTable) { + sos.writeZONERECORD(z); + } + } catch (IOException e) { + } + return baos.toByteArray(); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontInfo2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontInfo2Tag.java new file mode 100644 index 000000000..7356aec17 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontInfo2Tag.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.LANGCODE; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineFontInfo2Tag extends Tag { + + public int fontID; + public String fontName; + public boolean fontFlagsSmallText; + public boolean fontFlagsShiftJIS; + public boolean fontFlagsANSI; + public boolean fontFlagsItalic; + public boolean fontFlagsBold; + public boolean fontFlagsWideCodes; + public LANGCODE languageCode; + public int codeTable[]; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontID); + sos.writeUI8(fontName.getBytes().length); + sos.write(fontName.getBytes()); + sos.writeUB(2, 0); + sos.writeUB(1, fontFlagsSmallText ? 1 : 0); + sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0); + sos.writeUB(1, fontFlagsANSI ? 1 : 0); + sos.writeUB(1, fontFlagsItalic ? 1 : 0); + sos.writeUB(1, fontFlagsBold ? 1 : 0); + sos.writeUB(1, fontFlagsWideCodes ? 1 : 0); + sos.writeLANGCODE(languageCode); + for (int i = 0; i < codeTable.length; i++) { + sos.writeUI16(codeTable[i]); + } + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineFontInfo2Tag(byte data[], int version, long pos) throws IOException { + super(62, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontID = sis.readUI16(); + int fontNameLen = sis.readUI8(); + fontName = new String(sis.readBytes(fontNameLen)); + sis.readUB(2);//reserved + fontFlagsSmallText = sis.readUB(1) == 1; + fontFlagsShiftJIS = sis.readUB(1) == 1; + fontFlagsANSI = sis.readUB(1) == 1; + fontFlagsItalic = sis.readUB(1) == 1; + fontFlagsBold = sis.readUB(1) == 1; + fontFlagsWideCodes = sis.readUB(1) == 1; + languageCode = sis.readLANGCODE(); + codeTable = new int[sis.available() / 2]; + for (int i = 0; i < codeTable.length; i++) { + codeTable[i] = sis.readUI16(); + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineFontInfo2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontInfoTag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontInfoTag.java new file mode 100644 index 000000000..8e048c80a --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontInfoTag.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * + * + * @author JPEXS + */ +public class DefineFontInfoTag extends Tag { + + public int fontId; + public String fontName; + public boolean fontFlagsSmallText; + public boolean fontFlagsShiftJIS; + public boolean fontFlagsANSI; + public boolean fontFlagsItalic; + public boolean fontFlagsBold; + public boolean fontFlagsWideCodes; + public List codeTable; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(fontId); + sos.writeUI8(fontName.getBytes().length); + sos.write(fontName.getBytes()); + sos.writeUB(2, 0); //reserved + sos.writeUB(1, fontFlagsSmallText ? 1 : 0); + sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0); + sos.writeUB(1, fontFlagsANSI ? 1 : 0); + sos.writeUB(1, fontFlagsItalic ? 1 : 0); + sos.writeUB(1, fontFlagsBold ? 1 : 0); + sos.writeUB(1, fontFlagsWideCodes ? 1 : 0); + for (int code : codeTable) { + if (fontFlagsWideCodes) { + sos.writeUI16(code); + } else { + sos.writeUI8(code); + } + } + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineFontInfoTag(byte data[], int version, long pos) throws IOException { + super(13, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + fontId = sis.readUI16(); + int fontNameLen = sis.readUI8(); + fontName = new String(sis.readBytes(fontNameLen)); + sis.readUB(2); //reserved + fontFlagsSmallText = sis.readUB(1) == 1; + fontFlagsShiftJIS = sis.readUB(1) == 1; + fontFlagsANSI = sis.readUB(1) == 1; + fontFlagsItalic = sis.readUB(1) == 1; + fontFlagsBold = sis.readUB(1) == 1; + fontFlagsWideCodes = sis.readUB(1) == 1; + codeTable = new ArrayList(); + do { + if (fontFlagsWideCodes) { + codeTable.add(sis.readUI16()); + } else { + codeTable.add(sis.readUI8()); + } + } while (sis.available() > 0); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineFontInfo"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontNameTag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontNameTag.java index 88ff7a988..6ed954e0b 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFontNameTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontNameTag.java @@ -22,9 +22,9 @@ import java.io.IOException; public class DefineFontNameTag extends Tag { - private int fontId; - private String fontName; - private String fontCopyright; + public int fontId; + public String fontName; + public String fontCopyright; public DefineFontNameTag(byte[] data, int version, long pos) throws IOException { super(88, data, pos); diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontTag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontTag.java index aafd87146..c3e787b6b 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFontTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontTag.java @@ -18,20 +18,23 @@ package com.jpexs.asdec.tags; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.SHAPE; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; /** - * + * * * @author JPEXS */ public class DefineFontTag extends Tag { + public int fontId; + public int offsetTable[]; + public SHAPE glyphShapeTable[]; + /** * Gets data bytes * @@ -43,10 +46,16 @@ public class DefineFontTag extends Tag { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, version); - /*try { - //sos.write - } catch (IOException e) { - }*/ + try { + sos.writeUI16(fontId); + for (int offset : offsetTable) { + sos.writeUI16(offset); + } + for (SHAPE shape : glyphShapeTable) { + sos.writeSHAPE(shape, 1); + } + } catch (IOException e) { + } return baos.toByteArray(); } @@ -60,7 +69,18 @@ public class DefineFontTag extends Tag { public DefineFontTag(byte data[], int version, long pos) throws IOException { super(10, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - + fontId = sis.readUI16(); + int firstOffset = sis.readUI16(); + int nGlyphs = firstOffset / 2; + offsetTable = new int[nGlyphs]; + glyphShapeTable = new SHAPE[nGlyphs]; + offsetTable[0] = firstOffset; + for (int i = 1; i < nGlyphs; i++) { + offsetTable[i] = sis.readUI16(); + } + for (int i = 0; i < nGlyphs; i++) { + glyphShapeTable[i] = sis.readSHAPE(1); + } } /** diff --git a/trunk/src/com/jpexs/asdec/tags/DefineMorphShape2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineMorphShape2Tag.java new file mode 100644 index 000000000..21d0cf9c3 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineMorphShape2Tag.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.MORPHFILLSTYLEARRAY; +import com.jpexs.asdec.types.MORPHLINESTYLEARRAY; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.SHAPE; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineMorphShape2Tag extends Tag { + + public int characterId; + public RECT startBounds; + public RECT endBounds; + public RECT startEdgeBounds; + public RECT endEdgeBounds; + public boolean usesNonScalingStrokes; + public boolean usesScalingStrokes; + public MORPHFILLSTYLEARRAY morphFillStyles; + public MORPHLINESTYLEARRAY morphLineStyles; + public SHAPE startEdges; + public SHAPE endEdges; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterId); + sos.writeRECT(startBounds); + sos.writeRECT(endBounds); + sos.writeRECT(startEdgeBounds); + sos.writeRECT(endEdgeBounds); + sos.writeUB(6, 0); + sos.writeUB(1, usesNonScalingStrokes ? 1 : 0); + sos.writeUB(1, usesScalingStrokes ? 1 : 0); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 2); + sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 2); + sos2.writeSHAPE(startEdges, 1); + byte ba2[] = baos2.toByteArray(); + sos.writeUI32(ba2.length); + sos.write(ba2); + sos.writeSHAPE(endEdges, 1); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineMorphShape2Tag(byte data[], int version, long pos) throws IOException { + super(84, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterId = sis.readUI16(); + startBounds = sis.readRECT(); + endBounds = sis.readRECT(); + startEdgeBounds = sis.readRECT(); + endEdgeBounds = sis.readRECT(); + sis.readUB(6); //reserved + usesNonScalingStrokes = sis.readUB(1) == 1; + usesScalingStrokes = sis.readUB(1) == 1; + long offset = sis.readUI32(); + morphFillStyles = sis.readMORPHFILLSTYLEARRAY(); + morphLineStyles = sis.readMORPHLINESTYLEARRAY(2); + startEdges = sis.readSHAPE(1); + endEdges = sis.readSHAPE(1); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineMorphShape2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineMorphShapeTag.java b/trunk/src/com/jpexs/asdec/tags/DefineMorphShapeTag.java new file mode 100644 index 000000000..138682fd3 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineMorphShapeTag.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.MORPHFILLSTYLEARRAY; +import com.jpexs.asdec.types.MORPHLINESTYLEARRAY; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.SHAPE; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineMorphShapeTag extends Tag { + + public int characterId; + public RECT startBounds; + public RECT endBounds; + public MORPHFILLSTYLEARRAY morphFillStyles; + public MORPHLINESTYLEARRAY morphLineStyles; + public SHAPE startEdges; + public SHAPE endEdges; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterId); + sos.writeRECT(startBounds); + sos.writeRECT(endBounds); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 1); + sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 1); + sos2.writeSHAPE(startEdges, 1); + byte d[] = baos2.toByteArray(); + sos.writeUI32(d.length); + sos.write(d); + sos.writeSHAPE(endEdges, 1); + + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineMorphShapeTag(byte data[], int version, long pos) throws IOException { + super(46, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterId = sis.readUI16(); + startBounds = sis.readRECT(); + endBounds = sis.readRECT(); + long offset = sis.readUI32(); //ignore + morphFillStyles = sis.readMORPHFILLSTYLEARRAY(); + morphLineStyles = sis.readMORPHLINESTYLEARRAY(1); + startEdges = sis.readSHAPE(1); + endEdges = sis.readSHAPE(1); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineMorphShape"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineSceneAndFrameLabelDataTag.java b/trunk/src/com/jpexs/asdec/tags/DefineSceneAndFrameLabelDataTag.java index 7f80d3402..b2c1d7eec 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineSceneAndFrameLabelDataTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineSceneAndFrameLabelDataTag.java @@ -22,8 +22,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; /** * diff --git a/trunk/src/com/jpexs/asdec/tags/DefineShape2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineShape2Tag.java index 924681790..448e14afd 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineShape2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineShape2Tag.java @@ -23,15 +23,17 @@ import java.io.ByteArrayInputStream; import java.io.IOException; public class DefineShape2Tag extends Tag { + public int shapeId; public RECT shapeBounds; public SHAPEWITHSTYLE shapes; + public DefineShape2Tag(byte[] data, int version, long pos) throws IOException { super(22, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - shapeId=sis.readUI16(); - shapeBounds=sis.readRECT(); - shapes=sis.readSHAPEWITHSTYLE(2); + shapeId = sis.readUI16(); + shapeBounds = sis.readRECT(); + shapes = sis.readSHAPEWITHSTYLE(2); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineShape4Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineShape4Tag.java index c07757e2b..a752a82d9 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineShape4Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineShape4Tag.java @@ -31,18 +31,18 @@ public class DefineShape4Tag extends Tag { public boolean usesNonScalingStrokes; public boolean usesScalingStrokes; public SHAPEWITHSTYLE shapes; - + public DefineShape4Tag(byte[] data, int version, long pos) throws IOException { super(83, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - shapeId=sis.readUI16(); - shapeBounds=sis.readRECT(); - edgeBounds=sis.readRECT(); + shapeId = sis.readUI16(); + shapeBounds = sis.readRECT(); + edgeBounds = sis.readRECT(); sis.readUB(5); - usesFillWindingRule=sis.readUB(1)==1; - usesNonScalingStrokes=sis.readUB(1)==1; - usesScalingStrokes=sis.readUB(1)==1; - shapes=sis.readSHAPEWITHSTYLE(4); + usesFillWindingRule = sis.readUB(1) == 1; + usesNonScalingStrokes = sis.readUB(1) == 1; + usesScalingStrokes = sis.readUB(1) == 1; + shapes = sis.readSHAPEWITHSTYLE(4); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineShapeTag.java b/trunk/src/com/jpexs/asdec/tags/DefineShapeTag.java index c62c2909b..28ce4e36d 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineShapeTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineShapeTag.java @@ -27,12 +27,13 @@ public class DefineShapeTag extends Tag { public int shapeId; public RECT shapeBounds; public SHAPEWITHSTYLE shapes; + public DefineShapeTag(byte[] data, int version, long pos) throws IOException { - super(2, data, pos); + super(2, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - shapeId=sis.readUI16(); - shapeBounds=sis.readRECT(); - shapes=sis.readSHAPEWITHSTYLE(1); + shapeId = sis.readUI16(); + shapeBounds = sis.readRECT(); + shapes = sis.readSHAPEWITHSTYLE(1); } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/DefineSoundTag.java b/trunk/src/com/jpexs/asdec/tags/DefineSoundTag.java new file mode 100644 index 000000000..f6a2c7b75 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineSoundTag.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineSoundTag extends Tag { + + public int soundId; + public int soundFormat; + public static final int FORMAT_UNCOMPRESSED_NATIVE_ENDIAN = 0; + public static final int FORMAT_ADPCM = 1; + public static final int FORMAT_MP3 = 2; + public static final int FORMAT_UNCOMPRESSED_LITTLE_ENDIAN = 3; + public static final int FORMAT_NELLYMOSER16KHZ = 4; + public static final int FORMAT_NELLYMOSER8KHZ = 5; + public static final int FORMAT_NELLYMOSER = 6; + public static final int FORMAT_SPEEX = 11; + public int soundRate; + public boolean soundType;//true=stereo + public long soundSampleCount; + public byte soundData[]; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(soundId); + sos.writeUB(4, soundFormat); + sos.writeUB(2, soundRate); + sos.writeUB(1, soundType ? 1 : 0); + sos.writeUI32(soundSampleCount); + sos.write(soundData); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineSoundTag(byte data[], int version, long pos) throws IOException { + super(14, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + soundId = sis.readUI16(); + soundFormat = (int) sis.readUB(4); + soundRate = (int) sis.readUB(2); + soundType = sis.readUB(1) == 1; + soundSampleCount = sis.readUI32(); + soundData = sis.readBytes(sis.available()); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineSound"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java index be3cb0c92..c6292f7e7 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java @@ -16,12 +16,12 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.TagName; -import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.Main; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.abc.CopyOutputStream; +import com.jpexs.asdec.tags.base.Container; +import com.jpexs.asdec.tags.base.TagName; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/asdec/tags/DefineText2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineText2Tag.java new file mode 100644 index 000000000..64ca02e22 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineText2Tag.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.MATRIX; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.TEXTRECORD; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * + * + * @author JPEXS + */ +public class DefineText2Tag extends Tag { + + public int characterID; + public RECT textBounds; + public MATRIX textMatrix; + public int glyphBits; + public int advanceBits; + public List textRecords; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterID); + sos.writeRECT(textBounds); + sos.writeMatrix(textMatrix); + sos.writeUI8(glyphBits); + sos.writeUI8(advanceBits); + for (TEXTRECORD tr : textRecords) { + sos.writeTEXTRECORD(tr, true, glyphBits, advanceBits); + } + sos.writeUI8(0); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineText2Tag(byte data[], int version, long pos) throws IOException { + super(33, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterID = sis.readUI16(); + textBounds = sis.readRECT(); + textMatrix = sis.readMatrix(); + glyphBits = sis.readUI8(); + advanceBits = sis.readUI8(); + textRecords = new ArrayList(); + TEXTRECORD tr; + while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits)) != null) { + textRecords.add(tr); + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineText2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DefineTextTag.java b/trunk/src/com/jpexs/asdec/tags/DefineTextTag.java index 381fcddc0..4fa98d7a7 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineTextTag.java @@ -18,6 +18,9 @@ package com.jpexs.asdec.tags; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.MATRIX; +import com.jpexs.asdec.types.RECT; +import com.jpexs.asdec.types.TEXTRECORD; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,12 +29,19 @@ import java.util.ArrayList; import java.util.List; /** - * + * * * @author JPEXS */ public class DefineTextTag extends Tag { + public int characterID; + public RECT textBounds; + public MATRIX textMatrix; + public int glyphBits; + public int advanceBits; + public List textRecords; + /** * Gets data bytes * @@ -43,10 +53,18 @@ public class DefineTextTag extends Tag { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, version); - /*try { - //sos.write - } catch (IOException e) { - }*/ + try { + sos.writeUI16(characterID); + sos.writeRECT(textBounds); + sos.writeMatrix(textMatrix); + sos.writeUI8(glyphBits); + sos.writeUI8(advanceBits); + for (TEXTRECORD tr : textRecords) { + sos.writeTEXTRECORD(tr, false, glyphBits, advanceBits); + } + sos.writeUI8(0); + } catch (IOException e) { + } return baos.toByteArray(); } @@ -60,7 +78,16 @@ public class DefineTextTag extends Tag { public DefineTextTag(byte data[], int version, long pos) throws IOException { super(11, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - + characterID = sis.readUI16(); + textBounds = sis.readRECT(); + textMatrix = sis.readMatrix(); + glyphBits = sis.readUI8(); + advanceBits = sis.readUI8(); + textRecords = new ArrayList(); + TEXTRECORD tr; + while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits)) != null) { + textRecords.add(tr); + } } /** diff --git a/trunk/src/com/jpexs/asdec/tags/DefineVideoStreamTag.java b/trunk/src/com/jpexs/asdec/tags/DefineVideoStreamTag.java new file mode 100644 index 000000000..188dc241e --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/DefineVideoStreamTag.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class DefineVideoStreamTag extends Tag { + + public int characterId; + public int numFrames; + public int width; + public int height; + public int videoFlagsDeblocking; + public boolean videoFlagsSmoothing; + public int codecID; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(characterId); + sos.writeUI16(numFrames); + sos.writeUI16(width); + sos.writeUI16(height); + sos.writeUB(4, 0); + sos.writeUB(3, videoFlagsDeblocking); + sos.writeUB(1, videoFlagsSmoothing ? 1 : 0); + sos.writeUI8(codecID); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DefineVideoStreamTag(byte data[], int version, long pos) throws IOException { + super(60, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + characterId = sis.readUI16(); + numFrames = sis.readUI16(); + width = sis.readUI16(); + height = sis.readUI16(); + sis.readUB(4); + videoFlagsDeblocking = (int) sis.readUB(3); + videoFlagsSmoothing = sis.readUB(1) == 1; + codecID = sis.readUI8(); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "DefineVideoStream"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/DoActionTag.java b/trunk/src/com/jpexs/asdec/tags/DoActionTag.java index b8bcc289d..677551ba7 100644 --- a/trunk/src/com/jpexs/asdec/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DoActionTag.java @@ -16,9 +16,9 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.action.Action; +import com.jpexs.asdec.tags.base.ASMSource; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java index fd615b750..0f5734965 100644 --- a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java @@ -16,11 +16,11 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.TagName; -import com.jpexs.asdec.tags.base.ASMSource; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.action.Action; +import com.jpexs.asdec.tags.base.ASMSource; +import com.jpexs.asdec.tags.base.TagName; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/asdec/tags/EnableDebugger2Tag.java b/trunk/src/com/jpexs/asdec/tags/EnableDebugger2Tag.java index cdb4381ce..4ff1e26c2 100644 --- a/trunk/src/com/jpexs/asdec/tags/EnableDebugger2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/EnableDebugger2Tag.java @@ -30,6 +30,7 @@ import java.io.OutputStream; */ public class EnableDebugger2Tag extends Tag { + public int reserved; /** * MD5 hash of password */ @@ -47,7 +48,7 @@ public class EnableDebugger2Tag extends Tag { OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, version); try { - sos.writeUI16(0);//reserved + sos.writeUI16(reserved); sos.writeString(passwordHash); } catch (IOException e) { @@ -65,7 +66,7 @@ public class EnableDebugger2Tag extends Tag { public EnableDebugger2Tag(byte data[], int version, long pos) throws IOException { super(64, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - sis.readUI16(); //reserved + reserved = sis.readUI16(); passwordHash = sis.readString(); } diff --git a/trunk/src/com/jpexs/asdec/tags/EndTag.java b/trunk/src/com/jpexs/asdec/tags/EndTag.java index d4c334f8b..c6d6efc06 100644 --- a/trunk/src/com/jpexs/asdec/tags/EndTag.java +++ b/trunk/src/com/jpexs/asdec/tags/EndTag.java @@ -16,14 +16,7 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.SWFInputStream; -import com.jpexs.asdec.SWFOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; /** * Extends the functionality of the PlaceObject2Tag diff --git a/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java b/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java index e59966f5f..07c066015 100644 --- a/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java +++ b/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java @@ -54,7 +54,7 @@ public class ExportAssetsTag extends Tag { assets.put(characterId, name); } } - + /** * Gets data bytes * @@ -68,7 +68,7 @@ public class ExportAssetsTag extends Tag { SWFOutputStream sos = new SWFOutputStream(os, version); try { sos.writeUI16(assets.size()); - for(int characterId:assets.keySet()){ + for (int characterId : assets.keySet()) { sos.writeUI16(characterId); sos.writeString(assets.get(characterId)); } diff --git a/trunk/src/com/jpexs/asdec/tags/FileAttributesTag.java b/trunk/src/com/jpexs/asdec/tags/FileAttributesTag.java index c5ccf3eb3..e00ac32e7 100644 --- a/trunk/src/com/jpexs/asdec/tags/FileAttributesTag.java +++ b/trunk/src/com/jpexs/asdec/tags/FileAttributesTag.java @@ -25,27 +25,30 @@ import java.io.OutputStream; public class FileAttributesTag extends Tag { - private boolean useDirectBlit; - private boolean useGPU; - private boolean hasMetadata; - private boolean actionScript3; - private boolean useNetwork; + public boolean useDirectBlit; + public boolean useGPU; + public boolean hasMetadata; + public boolean actionScript3; + public boolean useNetwork; + private int reserved1; + private int reserved2; + private int reserved3; public FileAttributesTag(byte[] data, int version, long pos) throws IOException { super(69, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - sis.readUB(1); // reserved + reserved1 = (int) sis.readUB(1); // reserved // UB[1] == 0 (reserved) useDirectBlit = sis.readUB(1) != 0; useGPU = sis.readUB(1) != 0; hasMetadata = sis.readUB(1) != 0; actionScript3 = sis.readUB(1) != 0; - sis.readUB(2); // reserved + reserved2 = (int) sis.readUB(2); // reserved useNetwork = sis.readUB(1) != 0; // UB[24] == 0 (reserved) - sis.readUB(24); //reserved + reserved3 = (int) sis.readUB(24); //reserved } - + /** * Gets data bytes * @@ -58,24 +61,14 @@ public class FileAttributesTag extends Tag { OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, version); try { - sos.writeUB(1, 0); //reserved - if(useDirectBlit){ - sos.writeUB(1, 1); - } - if(useGPU){ - sos.writeUB(1, 1); - } - if(hasMetadata){ - sos.writeUB(1, 1); - } - if(actionScript3){ - sos.writeUB(1, 1); - } - sos.writeUB(2, 0); //reserved - if(useNetwork){ - sos.writeUB(1, 1); - } - sos.writeUB(24, 0); //reserved + sos.writeUB(1, reserved1); //reserved + sos.writeUB(1, useDirectBlit ? 1 : 0); + sos.writeUB(1, useGPU ? 1 : 0); + sos.writeUB(1, hasMetadata ? 1 : 0); + sos.writeUB(1, actionScript3 ? 1 : 0); + sos.writeUB(2, reserved2); //reserved + sos.writeUB(1, useNetwork ? 1 : 0); + sos.writeUB(24, reserved3); //reserved } catch (IOException e) { } return baos.toByteArray(); diff --git a/trunk/src/com/jpexs/asdec/tags/JPEGTablesTag.java b/trunk/src/com/jpexs/asdec/tags/JPEGTablesTag.java index e4bbd5dd2..193ecc8be 100644 --- a/trunk/src/com/jpexs/asdec/tags/JPEGTablesTag.java +++ b/trunk/src/com/jpexs/asdec/tags/JPEGTablesTag.java @@ -21,8 +21,7 @@ import java.io.IOException; public class JPEGTablesTag extends Tag { public JPEGTablesTag(byte[] data, long pos) throws IOException { - super(8, data, pos); - // TODO Auto-generated constructor stub + super(8, data, pos); //data is JPEG data } @Override diff --git a/trunk/src/com/jpexs/asdec/tags/MetadataTag.java b/trunk/src/com/jpexs/asdec/tags/MetadataTag.java index 4ad23cce5..cf9e7736a 100644 --- a/trunk/src/com/jpexs/asdec/tags/MetadataTag.java +++ b/trunk/src/com/jpexs/asdec/tags/MetadataTag.java @@ -25,18 +25,17 @@ import java.io.OutputStream; public class MetadataTag extends Tag { - private String xmlMetadata; + public String xmlMetadata; public MetadataTag(byte[] data, int version, long pos) { - super(77, data, pos); + super(77, data, pos); try { SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); xmlMetadata = sis.readString(); } catch (IOException ex) { - } } - + /** * Gets data bytes * diff --git a/trunk/src/com/jpexs/asdec/tags/NotDefinedTag.java b/trunk/src/com/jpexs/asdec/tags/NotDefinedTag.java index aecc19dec..11aca18b4 100644 --- a/trunk/src/com/jpexs/asdec/tags/NotDefinedTag.java +++ b/trunk/src/com/jpexs/asdec/tags/NotDefinedTag.java @@ -21,16 +21,16 @@ package com.jpexs.asdec.tags; * @author JPEXS */ public class NotDefinedTag extends Tag { + private String name; - public NotDefinedTag(String name,int id, byte[] data, long pos) { + + public NotDefinedTag(String name, int id, byte[] data, long pos) { super(id, data, pos); - this.name=name; + this.name = name; } @Override public String toString() { return name; } - - } diff --git a/trunk/src/com/jpexs/asdec/tags/PlaceObject2Tag.java b/trunk/src/com/jpexs/asdec/tags/PlaceObject2Tag.java index 62f22d1b6..d1c161108 100644 --- a/trunk/src/com/jpexs/asdec/tags/PlaceObject2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/PlaceObject2Tag.java @@ -16,11 +16,11 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.Main; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.abc.CopyOutputStream; +import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.types.CLIPACTIONS; import com.jpexs.asdec.types.CXFORMWITHALPHA; import com.jpexs.asdec.types.MATRIX; diff --git a/trunk/src/com/jpexs/asdec/tags/PlaceObject3Tag.java b/trunk/src/com/jpexs/asdec/tags/PlaceObject3Tag.java index 9aad07ef8..931c720fb 100644 --- a/trunk/src/com/jpexs/asdec/tags/PlaceObject3Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/PlaceObject3Tag.java @@ -16,11 +16,11 @@ */ package com.jpexs.asdec.tags; -import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.Main; import com.jpexs.asdec.SWFInputStream; import com.jpexs.asdec.SWFOutputStream; import com.jpexs.asdec.abc.CopyOutputStream; +import com.jpexs.asdec.tags.base.Container; import com.jpexs.asdec.types.CLIPACTIONS; import com.jpexs.asdec.types.CXFORMWITHALPHA; import com.jpexs.asdec.types.MATRIX; diff --git a/trunk/src/com/jpexs/asdec/tags/ProductInfoTag.java b/trunk/src/com/jpexs/asdec/tags/ProductInfoTag.java index ccc7e012a..b22db8e8a 100644 --- a/trunk/src/com/jpexs/asdec/tags/ProductInfoTag.java +++ b/trunk/src/com/jpexs/asdec/tags/ProductInfoTag.java @@ -22,13 +22,13 @@ import java.io.IOException; public class ProductInfoTag extends Tag { - private long productID; - private long edition; - private int majorVersion; - private int minorVersion; - private long buildLow; - private long buildHigh; - private long compilationDate; + public long productID; + public long edition; + public int majorVersion; + public int minorVersion; + public long buildLow; + public long buildHigh; + public long compilationDate; public ProductInfoTag(byte[] data, int version, long pos) throws IOException { super(41, data, pos); diff --git a/trunk/src/com/jpexs/asdec/tags/RemoveObject2Tag.java b/trunk/src/com/jpexs/asdec/tags/RemoveObject2Tag.java index fa7113676..9eaba8667 100644 --- a/trunk/src/com/jpexs/asdec/tags/RemoveObject2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/RemoveObject2Tag.java @@ -22,7 +22,7 @@ import java.io.IOException; public class RemoveObject2Tag extends Tag { - private int depth; + public int depth; public RemoveObject2Tag(byte[] data, int version, long pos) throws IOException { super(28, data, pos); diff --git a/trunk/src/com/jpexs/asdec/tags/ScriptLimitsTag.java b/trunk/src/com/jpexs/asdec/tags/ScriptLimitsTag.java index f427d68d4..d1fa3fee0 100644 --- a/trunk/src/com/jpexs/asdec/tags/ScriptLimitsTag.java +++ b/trunk/src/com/jpexs/asdec/tags/ScriptLimitsTag.java @@ -25,8 +25,8 @@ import java.io.OutputStream; public class ScriptLimitsTag extends Tag { - private int maxRecursionDepth; - private int scriptTimeoutSeconds; + public int maxRecursionDepth; + public int scriptTimeoutSeconds; public ScriptLimitsTag(byte[] data, int version, long pos) throws IOException { super(65, data, pos); @@ -53,7 +53,7 @@ public class ScriptLimitsTag extends Tag { } return baos.toByteArray(); } - + @Override public String toString() { return "ScriptLimits"; diff --git a/trunk/src/com/jpexs/asdec/tags/SetBackgroundColorTag.java b/trunk/src/com/jpexs/asdec/tags/SetBackgroundColorTag.java index ea9f23191..7c61b73f4 100644 --- a/trunk/src/com/jpexs/asdec/tags/SetBackgroundColorTag.java +++ b/trunk/src/com/jpexs/asdec/tags/SetBackgroundColorTag.java @@ -20,7 +20,7 @@ import com.jpexs.asdec.types.RGB; public class SetBackgroundColorTag extends Tag { - private RGB backgroundColor; + public RGB backgroundColor; public SetBackgroundColorTag(byte[] data, long pos) { super(9, data, pos); diff --git a/trunk/src/com/jpexs/asdec/tags/SetTabIndexTag.java b/trunk/src/com/jpexs/asdec/tags/SetTabIndexTag.java index 7be910c9e..0a86b31d5 100644 --- a/trunk/src/com/jpexs/asdec/tags/SetTabIndexTag.java +++ b/trunk/src/com/jpexs/asdec/tags/SetTabIndexTag.java @@ -79,6 +79,6 @@ public class SetTabIndexTag extends Tag { */ @Override public String toString() { - return ""; + return "SetTabIndex"; } } diff --git a/trunk/src/com/jpexs/asdec/tags/SoundStreamBlockTag.java b/trunk/src/com/jpexs/asdec/tags/SoundStreamBlockTag.java new file mode 100644 index 000000000..621490407 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/SoundStreamBlockTag.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import java.io.IOException; + +/** + * + * + * @author JPEXS + */ +public class SoundStreamBlockTag extends Tag { + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public SoundStreamBlockTag(byte data[], int version, long pos) throws IOException { + super(19, data, pos); //all data is streamSoundData + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "SoundStreamBlock"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/SoundStreamHead2Tag.java b/trunk/src/com/jpexs/asdec/tags/SoundStreamHead2Tag.java new file mode 100644 index 000000000..b079cc7f8 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/SoundStreamHead2Tag.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class SoundStreamHead2Tag extends Tag { + + public int playBackSoundRate; + public int playBackSoundSize; + public int playBackSoundType; + public int streamSoundCompression; + public int streamSoundRate; + public int streamSoundSize; + public int streamSoundType; + public int streamSoundSampleCount; + public int latencySeek; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUB(4, 0);//reserved + sos.writeUB(2, playBackSoundRate); + sos.writeUB(1, playBackSoundSize); + sos.writeUB(1, playBackSoundType); + sos.writeUB(4, streamSoundCompression); + sos.writeUB(2, streamSoundRate); + sos.writeUB(1, streamSoundSize); + sos.writeUB(1, streamSoundType); + sos.writeUI16(streamSoundSampleCount); + if (streamSoundCompression == 2) { + sos.writeSI16(latencySeek); + } + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public SoundStreamHead2Tag(byte data[], int version, long pos) throws IOException { + super(45, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + sis.readUB(4);//reserved + playBackSoundRate = (int) sis.readUB(2); + playBackSoundSize = (int) sis.readUB(1); + playBackSoundType = (int) sis.readUB(1); + streamSoundCompression = (int) sis.readUB(4); + streamSoundRate = (int) sis.readUB(2); + streamSoundSize = (int) sis.readUB(1); + streamSoundType = (int) sis.readUB(1); + streamSoundSampleCount = sis.readUI16(); + if (streamSoundCompression == 2) { + latencySeek = sis.readSI16(); + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "SoundStreamHead2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/SoundStreamHeadTag.java b/trunk/src/com/jpexs/asdec/tags/SoundStreamHeadTag.java new file mode 100644 index 000000000..5b3991f72 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/SoundStreamHeadTag.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class SoundStreamHeadTag extends Tag { + + public int playBackSoundRate; + public int playBackSoundSize; + public int playBackSoundType; + public int streamSoundCompression; + public int streamSoundRate; + public int streamSoundSize; + public int streamSoundType; + public int streamSoundSampleCount; + public int latencySeek; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUB(4, 0);//reserved + sos.writeUB(2, playBackSoundRate); + sos.writeUB(1, playBackSoundSize); + sos.writeUB(1, playBackSoundType); + sos.writeUB(4, streamSoundCompression); + sos.writeUB(2, streamSoundRate); + sos.writeUB(1, streamSoundSize); + sos.writeUB(1, streamSoundType); + sos.writeUI16(streamSoundSampleCount); + if (streamSoundCompression == 2) { + sos.writeSI16(latencySeek); + } + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public SoundStreamHeadTag(byte data[], int version, long pos) throws IOException { + super(18, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + sis.readUB(4);//reserved + playBackSoundRate = (int) sis.readUB(2); + playBackSoundSize = (int) sis.readUB(1); + playBackSoundType = (int) sis.readUB(1); + streamSoundCompression = (int) sis.readUB(4); + streamSoundRate = (int) sis.readUB(2); + streamSoundSize = (int) sis.readUB(1); + streamSoundType = (int) sis.readUB(1); + streamSoundSampleCount = sis.readUI16(); + if (streamSoundCompression == 2) { + latencySeek = sis.readSI16(); + } + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "SoundStreamHead"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/StartSound2Tag.java b/trunk/src/com/jpexs/asdec/tags/StartSound2Tag.java new file mode 100644 index 000000000..3ab57caba --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/StartSound2Tag.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.SOUNDINFO; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class StartSound2Tag extends Tag { + + public String soundClassName; + public SOUNDINFO soundInfo; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + /*try { + //sos.write + } catch (IOException e) { + }*/ + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public StartSound2Tag(byte data[], int version, long pos) throws IOException { + super(89, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + soundClassName = sis.readString(); + soundInfo = sis.readSOUNDINFO(); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "StartSound2"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/StartSoundTag.java b/trunk/src/com/jpexs/asdec/tags/StartSoundTag.java new file mode 100644 index 000000000..a75a2113b --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/StartSoundTag.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import com.jpexs.asdec.types.SOUNDINFO; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class StartSoundTag extends Tag { + + public int soundId; + public SOUNDINFO soundInfo; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(soundId); + sos.writeSOUNDINFO(soundInfo); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public StartSoundTag(byte data[], int version, long pos) throws IOException { + super(15, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + soundId = sis.readUI16(); + soundInfo = sis.readSOUNDINFO(); + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "StartSound"; + } +} diff --git a/trunk/src/com/jpexs/asdec/tags/SymbolClassTag.java b/trunk/src/com/jpexs/asdec/tags/SymbolClassTag.java index cc57eaf29..5acf1d71c 100644 --- a/trunk/src/com/jpexs/asdec/tags/SymbolClassTag.java +++ b/trunk/src/com/jpexs/asdec/tags/SymbolClassTag.java @@ -25,8 +25,8 @@ import java.io.OutputStream; public class SymbolClassTag extends Tag { - private int tagIDs[]; - private String classNames[]; + public int tagIDs[]; + public String classNames[]; public SymbolClassTag(byte[] data, int version, long pos) throws IOException { super(76, data, pos); diff --git a/trunk/src/com/jpexs/asdec/tags/Tag.java b/trunk/src/com/jpexs/asdec/tags/Tag.java index d1002a732..3ad73ccdc 100644 --- a/trunk/src/com/jpexs/asdec/tags/Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/Tag.java @@ -69,6 +69,15 @@ public class Tag { return data; } + /** + * Gets original read data + * + * @return Bytes of data + */ + public byte[] getOriginalData() { + return data; + } + /** * Returns string representation of the object * diff --git a/trunk/src/com/jpexs/asdec/tags/StubTag.java b/trunk/src/com/jpexs/asdec/tags/TagStub.java similarity index 88% rename from trunk/src/com/jpexs/asdec/tags/StubTag.java rename to trunk/src/com/jpexs/asdec/tags/TagStub.java index 5bd26f300..4c8316768 100644 --- a/trunk/src/com/jpexs/asdec/tags/StubTag.java +++ b/trunk/src/com/jpexs/asdec/tags/TagStub.java @@ -22,15 +22,13 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; /** - * + * * * @author JPEXS */ -public class StubTag extends Tag { +public class TagStub extends Tag { /** * Gets data bytes @@ -57,7 +55,7 @@ public class StubTag extends Tag { * @param version SWF version * @throws IOException */ - public StubTag(byte data[], int version, long pos) throws IOException { + public TagStub(byte data[], int version, long pos) throws IOException { super(0, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); diff --git a/trunk/src/com/jpexs/asdec/tags/VideoFrameTag.java b/trunk/src/com/jpexs/asdec/tags/VideoFrameTag.java new file mode 100644 index 000000000..a8c2508cd --- /dev/null +++ b/trunk/src/com/jpexs/asdec/tags/VideoFrameTag.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.tags; + +import com.jpexs.asdec.SWFInputStream; +import com.jpexs.asdec.SWFOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * + * @author JPEXS + */ +public class VideoFrameTag extends Tag { + + public int streamID; + public int frameNum; + public byte[] videoData; + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStream os = baos; + SWFOutputStream sos = new SWFOutputStream(os, version); + try { + sos.writeUI16(streamID); + sos.writeUI16(frameNum); + sos.write(videoData); + } catch (IOException e) { + } + return baos.toByteArray(); + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public VideoFrameTag(byte data[], int version, long pos) throws IOException { + super(61, data, pos); + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); + streamID = sis.readUI16(); + frameNum = sis.readUI16(); + videoData = sis.readBytes(sis.available()); //TODO: Parse video packets + } + + /** + * Returns string representation of the object + * + * @return String representation of the object + */ + @Override + public String toString() { + return "VideoFrame"; + } +} diff --git a/trunk/src/com/jpexs/asdec/types/CXFORM.java b/trunk/src/com/jpexs/asdec/types/CXFORM.java index f1320daa7..f53767ee4 100644 --- a/trunk/src/com/jpexs/asdec/types/CXFORM.java +++ b/trunk/src/com/jpexs/asdec/types/CXFORM.java @@ -32,9 +32,7 @@ public class CXFORM { * Has color multiply values */ public boolean hasMultTerms; - public int nbits; - /** * Red multiply value */ @@ -47,7 +45,6 @@ public class CXFORM { * Blue multiply value */ public int blueMultTerm; - /** * Red addition value */ @@ -60,5 +57,4 @@ public class CXFORM { * Blue addition value */ public int blueAddTerm; - } diff --git a/trunk/src/com/jpexs/asdec/types/FILLSTYLE.java b/trunk/src/com/jpexs/asdec/types/FILLSTYLE.java index 9370255f4..71cf0beb7 100644 --- a/trunk/src/com/jpexs/asdec/types/FILLSTYLE.java +++ b/trunk/src/com/jpexs/asdec/types/FILLSTYLE.java @@ -21,16 +21,16 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class FILLSTYLE { + public int fillStyleType; - public static final int SOLID=0x0; - public static final int LINEAR_GRADIENT=0x10; - public static final int RADIAL_GRADIENT=0x12; - public static final int FOCAL_RADIAL_GRADIENT=0x13; - public static final int REPEATING_BITMAP=0x40; - public static final int CLIPPED_BITMAP=0x41; - public static final int NON_SMOOTHED_REPEATING_BITMAP=0x42; - public static final int NON_SMOOTHED_CLIPPED_BITMAP=0x43; - + public static final int SOLID = 0x0; + public static final int LINEAR_GRADIENT = 0x10; + public static final int RADIAL_GRADIENT = 0x12; + public static final int FOCAL_RADIAL_GRADIENT = 0x13; + public static final int REPEATING_BITMAP = 0x40; + public static final int CLIPPED_BITMAP = 0x41; + public static final int NON_SMOOTHED_REPEATING_BITMAP = 0x42; + public static final int NON_SMOOTHED_CLIPPED_BITMAP = 0x43; public boolean inShape3; public RGB color; public RGBA colorA; //Shape3 @@ -39,5 +39,4 @@ public class FILLSTYLE { public FOCALGRADIENT focalGradient; public int bitmapId; public MATRIX bitmapMatrix; - } diff --git a/trunk/src/com/jpexs/asdec/types/FILLSTYLEARRAY.java b/trunk/src/com/jpexs/asdec/types/FILLSTYLEARRAY.java index fa5469dea..c7b833478 100644 --- a/trunk/src/com/jpexs/asdec/types/FILLSTYLEARRAY.java +++ b/trunk/src/com/jpexs/asdec/types/FILLSTYLEARRAY.java @@ -21,5 +21,6 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class FILLSTYLEARRAY { + public FILLSTYLE fillStyles[]; } diff --git a/trunk/src/com/jpexs/asdec/types/FOCALGRADIENT.java b/trunk/src/com/jpexs/asdec/types/FOCALGRADIENT.java index 75809c079..4fa32631a 100644 --- a/trunk/src/com/jpexs/asdec/types/FOCALGRADIENT.java +++ b/trunk/src/com/jpexs/asdec/types/FOCALGRADIENT.java @@ -21,10 +21,9 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class FOCALGRADIENT { + public int spreadMode; public int interPolationMode; - public GRADRECORD gradientRecords[]; public float focalPoint; - } diff --git a/trunk/src/com/jpexs/asdec/types/GLYPHENTRY.java b/trunk/src/com/jpexs/asdec/types/GLYPHENTRY.java new file mode 100644 index 000000000..facf375f4 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/GLYPHENTRY.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class GLYPHENTRY { + + public int glyphIndex; + public int glyphAdvance; +} diff --git a/trunk/src/com/jpexs/asdec/types/GRADIENT.java b/trunk/src/com/jpexs/asdec/types/GRADIENT.java index f90994bcd..3f9982760 100644 --- a/trunk/src/com/jpexs/asdec/types/GRADIENT.java +++ b/trunk/src/com/jpexs/asdec/types/GRADIENT.java @@ -21,20 +21,16 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class GRADIENT { + public int spreadMode; - - public static final int SPREAD_PAD_MODE=0; - public static final int SPREAD_REFLECT_MODE=1; - public static final int SPREAD_REPAT_MODE=2; - public static final int SPREAD_RESERVED=3; - + public static final int SPREAD_PAD_MODE = 0; + public static final int SPREAD_REFLECT_MODE = 1; + public static final int SPREAD_REPAT_MODE = 2; + public static final int SPREAD_RESERVED = 3; public int interPolationMode; - - public static final int INTERPOLATION_RGB_MODE=0; - public static final int INTERPOLATION_LINEAR_RGB_MODE=1; - public static final int INTERPOLATION_RESERVED1=2; - public static final int INTERPOLATION_RESERVED2=3; - + public static final int INTERPOLATION_RGB_MODE = 0; + public static final int INTERPOLATION_LINEAR_RGB_MODE = 1; + public static final int INTERPOLATION_RESERVED1 = 2; + public static final int INTERPOLATION_RESERVED2 = 3; public GRADRECORD gradientRecords[]; - } diff --git a/trunk/src/com/jpexs/asdec/types/GRADRECORD.java b/trunk/src/com/jpexs/asdec/types/GRADRECORD.java index 82efd5864..cfe31fa0f 100644 --- a/trunk/src/com/jpexs/asdec/types/GRADRECORD.java +++ b/trunk/src/com/jpexs/asdec/types/GRADRECORD.java @@ -21,9 +21,9 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class GRADRECORD { + public int ratio; public boolean inShape3; public RGB color; public RGBA colorA; - } diff --git a/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java b/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java new file mode 100644 index 000000000..7643eb731 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * Represents 24-bit red, green, blue value + * + * @author JPEXS + */ +public class KERNINGRECORD { + + public int fontKerningCode1; + public int fontKerningCode2; + public int fontKerningAdjustment; +} diff --git a/trunk/src/com/jpexs/asdec/types/LANGCODE.java b/trunk/src/com/jpexs/asdec/types/LANGCODE.java new file mode 100644 index 000000000..c97a7bd47 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/LANGCODE.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class LANGCODE { + + public int languageCode; +} diff --git a/trunk/src/com/jpexs/asdec/types/LINESTYLE.java b/trunk/src/com/jpexs/asdec/types/LINESTYLE.java index d5035eb2b..9deb80848 100644 --- a/trunk/src/com/jpexs/asdec/types/LINESTYLE.java +++ b/trunk/src/com/jpexs/asdec/types/LINESTYLE.java @@ -21,8 +21,8 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class LINESTYLE { + public int width; public RGB color; public RGBA colorA; - } diff --git a/trunk/src/com/jpexs/asdec/types/LINESTYLE2.java b/trunk/src/com/jpexs/asdec/types/LINESTYLE2.java index 2cb7481a9..6e797c4b3 100644 --- a/trunk/src/com/jpexs/asdec/types/LINESTYLE2.java +++ b/trunk/src/com/jpexs/asdec/types/LINESTYLE2.java @@ -21,27 +21,23 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class LINESTYLE2 { + public int width; public int startCapStyle; public int joinStyle; - - public static final int ROUND_JOIN=0; - public static final int BEVEL_JOIN=1; - public static final int MITER_JOIN=2; - + public static final int ROUND_JOIN = 0; + public static final int BEVEL_JOIN = 1; + public static final int MITER_JOIN = 2; public boolean hasFillFlag; public boolean noHScaleFlag; public boolean noVScaleFlag; public boolean pixelHintingFlag; public boolean noClose; public int endCapStyle; - - public static final int ROUND_CAP=0; - public static final int NO_CAP=1; - public static final int SQUARE_CAP=2; - + public static final int ROUND_CAP = 0; + public static final int NO_CAP = 1; + public static final int SQUARE_CAP = 2; public int miterLimitFactor; public RGBA color; public FILLSTYLE fillType; - } diff --git a/trunk/src/com/jpexs/asdec/types/LINESTYLEARRAY.java b/trunk/src/com/jpexs/asdec/types/LINESTYLEARRAY.java index f3f698f20..9dea247ed 100644 --- a/trunk/src/com/jpexs/asdec/types/LINESTYLEARRAY.java +++ b/trunk/src/com/jpexs/asdec/types/LINESTYLEARRAY.java @@ -21,6 +21,7 @@ package com.jpexs.asdec.types; * @author JPEXS */ public class LINESTYLEARRAY { + public LINESTYLE lineStyles[]; public LINESTYLE2 lineStyles2[]; } diff --git a/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLE.java b/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLE.java new file mode 100644 index 000000000..52adb996d --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLE.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHFILLSTYLE { + + public int fillStyleType; + public static final int SOLID = 0x0; + public static final int LINEAR_GRADIENT = 0x10; + public static final int RADIAL_GRADIENT = 0x12; + public static final int REPEATING_BITMAP = 0x40; + public static final int CLIPPED_BITMAP = 0x41; + public static final int NON_SMOOTHED_REPEATING_BITMAP = 0x42; + public static final int NON_SMOOTHED_CLIPPED_BITMAP = 0x43; + public RGBA startColor; + public RGBA endColor; + public MATRIX startGradientMatrix; + public MATRIX endGradientMatrix; + public MORPHGRADIENT gradient; + public int bitmapId; + public MATRIX startBitmapMatrix; + public MATRIX endBitmapMatrix; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLEARRAY.java b/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLEARRAY.java new file mode 100644 index 000000000..0a4c325b4 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHFILLSTYLEARRAY.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHFILLSTYLEARRAY { + + public MORPHFILLSTYLE fillStyles[]; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHGRADIENT.java b/trunk/src/com/jpexs/asdec/types/MORPHGRADIENT.java new file mode 100644 index 000000000..3b0067520 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHGRADIENT.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHGRADIENT { + + public int numGradients; + public MORPHGRADRECORD gradientRecords[]; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHGRADRECORD.java b/trunk/src/com/jpexs/asdec/types/MORPHGRADRECORD.java new file mode 100644 index 000000000..fcc362255 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHGRADRECORD.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHGRADRECORD { + + public int startRatio; + public RGBA startColor; + public int endRatio; + public RGBA endColor; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE.java b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE.java new file mode 100644 index 000000000..64e8fd6e6 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHLINESTYLE { + + public int startWidth; + public int endWidth; + public RGBA startColor; + public RGBA endColor; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE2.java b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE2.java new file mode 100644 index 000000000..468d1d0a9 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLE2.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHLINESTYLE2 { + + public int startWidth; + public int endWidth; + public int startCapStyle; + public int joinStyle; + public static final int ROUND_JOIN = 0; + public static final int BEVEL_JOIN = 1; + public static final int MITER_JOIN = 2; + public boolean hasFillFlag; + public boolean noHScaleFlag; + public boolean noVScaleFlag; + public boolean pixelHintingFlag; + public boolean noClose; + public int endCapStyle; + public static final int ROUND_CAP = 0; + public static final int NO_CAP = 1; + public static final int SQUARE_CAP = 2; + public int miterLimitFactor; + public RGBA startColor; + public RGBA endColor; + public MORPHFILLSTYLE fillType; +} diff --git a/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLEARRAY.java b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLEARRAY.java new file mode 100644 index 000000000..51768330f --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/MORPHLINESTYLEARRAY.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class MORPHLINESTYLEARRAY { + + public MORPHLINESTYLE lineStyles[]; + public MORPHLINESTYLE2 lineStyles2[]; +} diff --git a/trunk/src/com/jpexs/asdec/types/SHAPE.java b/trunk/src/com/jpexs/asdec/types/SHAPE.java index e1be3132c..a9115b618 100644 --- a/trunk/src/com/jpexs/asdec/types/SHAPE.java +++ b/trunk/src/com/jpexs/asdec/types/SHAPE.java @@ -24,6 +24,7 @@ import java.util.List; * @author JPEXS */ public class SHAPE { + public int numFillBits; public int numLineBits; public List shapeRecords; diff --git a/trunk/src/com/jpexs/asdec/types/SHAPEWITHSTYLE.java b/trunk/src/com/jpexs/asdec/types/SHAPEWITHSTYLE.java index e87d87977..1d53adc7e 100644 --- a/trunk/src/com/jpexs/asdec/types/SHAPEWITHSTYLE.java +++ b/trunk/src/com/jpexs/asdec/types/SHAPEWITHSTYLE.java @@ -24,9 +24,10 @@ import java.util.List; * @author JPEXS */ public class SHAPEWITHSTYLE { + public FILLSTYLEARRAY fillStyles; public LINESTYLEARRAY lineStyles; public int numFillBits; - public int numLineBits; + public int numLineBits; public List shapeRecords; } diff --git a/trunk/src/com/jpexs/asdec/types/SOUNDENVELOPE.java b/trunk/src/com/jpexs/asdec/types/SOUNDENVELOPE.java new file mode 100644 index 000000000..91a9886db --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/SOUNDENVELOPE.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class SOUNDENVELOPE { + + public long pos44; + public int leftLevel; + public int rightLevel; +} diff --git a/trunk/src/com/jpexs/asdec/types/SOUNDINFO.java b/trunk/src/com/jpexs/asdec/types/SOUNDINFO.java new file mode 100644 index 000000000..0bd774376 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/SOUNDINFO.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class SOUNDINFO { + + public boolean syncStop; + public boolean syncNoMultiple; + public boolean hasEnvelope; + public boolean hasLoops; + public boolean hasOutPoint; + public boolean hasInPoint; + public long inPoint; + public long outPoint; + public int loopCount; + public SOUNDENVELOPE envelopeRecords[]; +} diff --git a/trunk/src/com/jpexs/asdec/types/TEXTRECORD.java b/trunk/src/com/jpexs/asdec/types/TEXTRECORD.java new file mode 100644 index 000000000..e720a1da2 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/TEXTRECORD.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * + * @author JPEXS + */ +public class TEXTRECORD { + + public boolean styleFlagsHasFont; + public boolean styleFlagsHasColor; + public boolean styleFlagsHasYOffset; + public boolean styleFlagsHasXOffset; + public int fontId; + public RGB textColor; + public RGBA textColorA; + public int xOffset; + public int yOffset; + public int textHeight; + public GLYPHENTRY glyphEntries[]; +} diff --git a/trunk/src/com/jpexs/asdec/types/ZONEDATA.java b/trunk/src/com/jpexs/asdec/types/ZONEDATA.java new file mode 100644 index 000000000..e67d85968 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/ZONEDATA.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * Represents 32-bit alpha, red, green and blue value + * + * @author JPEXS + */ +public class ZONEDATA { + + public float alignmentCoordinate; + public float range; +} diff --git a/trunk/src/com/jpexs/asdec/types/ZONERECORD.java b/trunk/src/com/jpexs/asdec/types/ZONERECORD.java new file mode 100644 index 000000000..c0e336518 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/types/ZONERECORD.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.asdec.types; + +/** + * Represents 32-bit alpha, red, green and blue value + * + * @author JPEXS + */ +public class ZONERECORD { + + public ZONEDATA zonedata[]; + public boolean zoneMaskX; + public boolean zoneMaskY; +} diff --git a/trunk/src/com/jpexs/asdec/types/shaperecords/CurvedEdgeRecord.java b/trunk/src/com/jpexs/asdec/types/shaperecords/CurvedEdgeRecord.java index 201fa6d5d..05538a59e 100644 --- a/trunk/src/com/jpexs/asdec/types/shaperecords/CurvedEdgeRecord.java +++ b/trunk/src/com/jpexs/asdec/types/shaperecords/CurvedEdgeRecord.java @@ -16,17 +16,22 @@ */ package com.jpexs.asdec.types.shaperecords; - /** * * @author JPEXS */ -public class CurvedEdgeRecord implements SHAPERECORD{ - public int typeFlag=1; - public int straightFlag=0; +public class CurvedEdgeRecord implements SHAPERECORD { + + public int typeFlag = 1; + public int straightFlag = 0; public int numBits; public int controlDeltaX; public int controlDeltaY; public int anchorDeltaX; public int anchorDeltaY; + + @Override + public String toString() { + return "[CurvedEdgeRecord numBits=" + numBits + ", controlDeltaX=" + controlDeltaX + ", controlDeltaY=" + controlDeltaY + ", anchorDeltaX=" + anchorDeltaX + ". anchorDeltaY=" + anchorDeltaY + "]"; + } } diff --git a/trunk/src/com/jpexs/asdec/types/shaperecords/EndShapeRecord.java b/trunk/src/com/jpexs/asdec/types/shaperecords/EndShapeRecord.java index 30b14a648..5e8e7c460 100644 --- a/trunk/src/com/jpexs/asdec/types/shaperecords/EndShapeRecord.java +++ b/trunk/src/com/jpexs/asdec/types/shaperecords/EndShapeRecord.java @@ -20,7 +20,13 @@ package com.jpexs.asdec.types.shaperecords; * * @author JPEXS */ -public class EndShapeRecord implements SHAPERECORD{ - public int typeFlag=0; - public int endOfShape=0; +public class EndShapeRecord implements SHAPERECORD { + + public int typeFlag = 0; + public int endOfShape = 0; + + @Override + public String toString() { + return "[EndShapeRecord]"; + } } diff --git a/trunk/src/com/jpexs/asdec/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/asdec/types/shaperecords/SHAPERECORD.java index 653aad4f9..c318ba316 100644 --- a/trunk/src/com/jpexs/asdec/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/asdec/types/shaperecords/SHAPERECORD.java @@ -21,5 +21,4 @@ package com.jpexs.asdec.types.shaperecords; * @author JPEXS */ public interface SHAPERECORD { - } diff --git a/trunk/src/com/jpexs/asdec/types/shaperecords/StraightEdgeRecord.java b/trunk/src/com/jpexs/asdec/types/shaperecords/StraightEdgeRecord.java index 9969d29e2..34eede43d 100644 --- a/trunk/src/com/jpexs/asdec/types/shaperecords/StraightEdgeRecord.java +++ b/trunk/src/com/jpexs/asdec/types/shaperecords/StraightEdgeRecord.java @@ -16,17 +16,22 @@ */ package com.jpexs.asdec.types.shaperecords; - /** * * @author JPEXS */ -public class StraightEdgeRecord implements SHAPERECORD{ - public int typeFlag=1; - public int straightFlag=1; +public class StraightEdgeRecord implements SHAPERECORD { + + public int typeFlag = 1; + public int straightFlag = 1; public int numBits; public boolean generalLineFlag; public boolean vertLineFlag; public int deltaX; - public int deltaY; + public int deltaY; + + @Override + public String toString() { + return "[StraightEdgeRecord numBits=" + numBits + ", generalLineFlag=" + generalLineFlag + ", vertLineFlag=" + vertLineFlag + ", deltaX=" + deltaX + ", deltaY=" + deltaY + "]"; + } } diff --git a/trunk/src/com/jpexs/asdec/types/shaperecords/StyleChangeRecord.java b/trunk/src/com/jpexs/asdec/types/shaperecords/StyleChangeRecord.java index 4ea1e7f96..3f2e53fb7 100644 --- a/trunk/src/com/jpexs/asdec/types/shaperecords/StyleChangeRecord.java +++ b/trunk/src/com/jpexs/asdec/types/shaperecords/StyleChangeRecord.java @@ -23,8 +23,9 @@ import com.jpexs.asdec.types.LINESTYLEARRAY; * * @author JPEXS */ -public class StyleChangeRecord implements SHAPERECORD{ - public int typeFlag=0; +public class StyleChangeRecord implements SHAPERECORD { + + public int typeFlag = 0; public boolean stateNewStyles; public boolean stateLineStyle; public boolean stateFillStyle1; @@ -40,5 +41,11 @@ public class StyleChangeRecord implements SHAPERECORD{ public LINESTYLEARRAY lineStyles; public int numFillBits; public int numLineBits; - + + @Override + public String toString() { + return "[StyleChangeRecord stateNewStyles=" + stateNewStyles + ", stateLineStyle=" + stateLineStyle + ",stateFillStyle1=" + stateFillStyle1 + "," + + " stateFillStyle0=" + stateFillStyle0 + ", stateMoveTo=" + stateMoveTo + ", moveBits=" + moveBits + ", moveDeltaX=" + moveDeltaX + ", moveDeltaY=" + moveDeltaY + "," + + " fillStyle0=" + fillStyle0 + ", fillStyle1=" + fillStyle1 + ", lineStyle=" + lineStyle + ", fillStyles=" + fillStyles + ", lineStyles=" + lineStyles + ", numFillBits=" + numFillBits + ", numLineBits=" + numLineBits + "]"; + } }