From 3b9ad8586855586ab327281ab3618186b281ccfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 4 Jan 2013 22:48:40 +0100 Subject: [PATCH] Fixed some tags, Image export stub --- trunk/src/com/jpexs/asdec/Main.java | 4 +- trunk/src/com/jpexs/asdec/SWF.java | 103 ++++++++++++++++++ trunk/src/com/jpexs/asdec/SWFInputStream.java | 35 +++--- .../src/com/jpexs/asdec/SWFOutputStream.java | 12 +- .../jpexs/asdec/tags/DefineBitsJPEG2Tag.java | 4 +- .../jpexs/asdec/tags/DefineButton2Tag.java | 5 +- .../com/jpexs/asdec/tags/DefineButtonTag.java | 5 +- .../com/jpexs/asdec/tags/DefineFont3Tag.java | 32 +++++- .../asdec/tags/DefineFontAlignZonesTag.java | 3 +- .../com/jpexs/asdec/tags/DefineSpriteTag.java | 5 +- .../com/jpexs/asdec/tags/DoInitActionTag.java | 5 +- .../com/jpexs/asdec/tags/ExportAssetsTag.java | 19 ++-- .../com/jpexs/asdec/types/KERNINGRECORD.java | 7 ++ trunk/src/com/jpexs/asdec/types/ZONEDATA.java | 11 +- .../src/com/jpexs/asdec/types/ZONERECORD.java | 13 +++ 15 files changed, 215 insertions(+), 48 deletions(-) diff --git a/trunk/src/com/jpexs/asdec/Main.java b/trunk/src/com/jpexs/asdec/Main.java index 51b2c6f30..c9d905d7d 100644 --- a/trunk/src/com/jpexs/asdec/Main.java +++ b/trunk/src/com/jpexs/asdec/Main.java @@ -23,7 +23,9 @@ import com.jpexs.asdec.gui.LoadingDialog; import com.jpexs.asdec.gui.ModeFrame; import com.jpexs.asdec.gui.View; import com.jpexs.asdec.gui.proxy.ProxyFrame; +import com.jpexs.asdec.tags.DefineBitsTag; import com.jpexs.asdec.tags.DoABCTag; +import com.jpexs.asdec.tags.JPEGTablesTag; import com.jpexs.asdec.tags.Tag; import java.awt.*; import java.awt.event.ActionEvent; @@ -540,7 +542,7 @@ public class Main { } try { dump_tags = true; - parseSWF(args[pos + 1]); + SWF swf = parseSWF(args[pos + 1]); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); System.exit(1); diff --git a/trunk/src/com/jpexs/asdec/SWF.java b/trunk/src/com/jpexs/asdec/SWF.java index d5f1c4ede..affa82072 100644 --- a/trunk/src/com/jpexs/asdec/SWF.java +++ b/trunk/src/com/jpexs/asdec/SWF.java @@ -19,13 +19,19 @@ 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.DefineBitsJPEG2Tag; +import com.jpexs.asdec.tags.DefineBitsJPEG3Tag; +import com.jpexs.asdec.tags.DefineBitsJPEG4Tag; +import com.jpexs.asdec.tags.DefineBitsTag; import com.jpexs.asdec.tags.DoABCTag; +import com.jpexs.asdec.tags.JPEGTablesTag; 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.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.zip.DeflaterOutputStream; @@ -434,4 +440,101 @@ public class SWF { listener.handleEvent(event, data); } } + + private String getImageFormat(byte data[]) { + if (hasErrorHeader(data)) { + return "jpg"; + } + if (data.length > 2 && ((data[0] & 0xff) == 0xff) && ((data[1] & 0xff) == 0xd8)) { + return "jpg"; + } + if (data.length > 6 && ((data[0] & 0xff) == 0x47) && ((data[1] & 0xff) == 0x49) && ((data[2] & 0xff) == 0x46) && ((data[3] & 0xff) == 0x38) && ((data[4] & 0xff) == 0x39) && ((data[5] & 0xff) == 0x61)) { + return "gif"; + } + + if (data.length > 8 && ((data[0] & 0xff) == 0x89) && ((data[1] & 0xff) == 0x50) && ((data[2] & 0xff) == 0x4e) && ((data[3] & 0xff) == 0x47) && ((data[4] & 0xff) == 0x0d) && ((data[5] & 0xff) == 0x0a) && ((data[6] & 0xff) == 0x1a) && ((data[7] & 0xff) == 0x0a)) { + return "png"; + } + + return "unk"; + } + + private boolean hasErrorHeader(byte data[]) { + if (data.length > 4) { + if ((data[0] & 0xff) == 0xff) { + if ((data[1] & 0xff) == 0xd9) { + if ((data[2] & 0xff) == 0xff) { + if ((data[3] & 0xff) == 0xd8) { + return true; + } + } + } + } + } + return false; + } + + public void exportImages(String outdir) throws IOException { + JPEGTablesTag jtt = null; + for (Tag t : tags) { + if (t instanceof JPEGTablesTag) { + jtt = (JPEGTablesTag) t; + } + } + + for (Tag t : tags) { + if ((t instanceof DefineBitsJPEG2Tag)||(t instanceof DefineBitsJPEG3Tag)||(t instanceof DefineBitsJPEG4Tag)) { + byte imageData[]=null; + int characterID=0; + if(t instanceof DefineBitsJPEG2Tag){ + imageData=((DefineBitsJPEG2Tag)t).imageData; + characterID=((DefineBitsJPEG2Tag)t).characterID; + } + if(t instanceof DefineBitsJPEG3Tag){ + imageData=((DefineBitsJPEG3Tag)t).imageData; + characterID=((DefineBitsJPEG3Tag)t).characterID; + } + if(t instanceof DefineBitsJPEG4Tag){ + imageData=((DefineBitsJPEG4Tag)t).imageData; + characterID=((DefineBitsJPEG4Tag)t).characterID; + } + + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + characterID + "."+getImageFormat(imageData)); + if (hasErrorHeader(imageData)) { + fos.write(imageData,4,imageData.length-4); + } else { + fos.write(imageData); + } + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } + } + if ((jtt != null) && (t instanceof DefineBitsTag)) { + DefineBitsTag dbt = (DefineBitsTag) t; + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + dbt.characterID + ".jpg"); + byte data[] = jtt.getData(10); + fos.write(data, hasErrorHeader(data) ? 4 : 0, data.length - (hasErrorHeader(data) ? 6 : 2)); + fos.write(dbt.jpegData, hasErrorHeader(dbt.jpegData) ? 6 : 2, dbt.jpegData.length - (hasErrorHeader(data) ? 6 : 2)); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } + } + } + } } diff --git a/trunk/src/com/jpexs/asdec/SWFInputStream.java b/trunk/src/com/jpexs/asdec/SWFInputStream.java index 94d4b218b..82e159d00 100644 --- a/trunk/src/com/jpexs/asdec/SWFInputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFInputStream.java @@ -1502,10 +1502,10 @@ public class SWFInputStream extends InputStream { * @return GRADRECORD value * @throws IOException */ - public GRADRECORD readGRADRECORD(boolean inShape3) throws IOException { + public GRADRECORD readGRADRECORD(int shapeNum) throws IOException { GRADRECORD ret = new GRADRECORD(); ret.ratio = readUI8(); - if (ret.inShape3 = inShape3) { + if (shapeNum >= 3) { ret.colorA = readRGBA(); } else { ret.color = readRGB(); @@ -1519,14 +1519,14 @@ public class SWFInputStream extends InputStream { * @return GRADIENT value * @throws IOException */ - public GRADIENT readGRADIENT(boolean inShape3) throws IOException { + public GRADIENT readGRADIENT(int shapeNum) throws IOException { GRADIENT ret = new GRADIENT(); ret.spreadMode = (int) readUB(2); ret.interPolationMode = (int) readUB(2); int numGradients = (int) readUB(4); ret.gradientRecords = new GRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(inShape3); + ret.gradientRecords[i] = readGRADRECORD(shapeNum); } return ret; @@ -1538,14 +1538,14 @@ public class SWFInputStream extends InputStream { * @return FOCALGRADIENT value * @throws IOException */ - public FOCALGRADIENT readFOCALGRADIENT(boolean inShape3) throws IOException { + public FOCALGRADIENT readFOCALGRADIENT(int shapeNum) throws IOException { FOCALGRADIENT ret = new FOCALGRADIENT(); ret.spreadMode = (int) readUB(2); ret.interPolationMode = (int) readUB(2); int numGradients = (int) readUB(4); ret.gradientRecords = new GRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(inShape3); + ret.gradientRecords[i] = readGRADRECORD(shapeNum); } ret.focalPoint = readFIXED8(); return ret; @@ -1557,11 +1557,11 @@ public class SWFInputStream extends InputStream { * @return FILLSTYLE value * @throws IOException */ - public FILLSTYLE readFILLSTYLE(boolean inShape3) throws IOException { + public FILLSTYLE readFILLSTYLE(int shapeNum) throws IOException { FILLSTYLE ret = new FILLSTYLE(); ret.fillStyleType = readUI8(); if (ret.fillStyleType == FILLSTYLE.SOLID) { - if (ret.inShape3 = inShape3) { + if (shapeNum >= 3) { ret.colorA = readRGBA(); } else { ret.color = readRGB(); @@ -1574,10 +1574,10 @@ public class SWFInputStream extends InputStream { } if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { - ret.gradient = readGRADIENT(inShape3); + ret.gradient = readGRADIENT(shapeNum); } if (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { - ret.focalGradient = readFOCALGRADIENT(inShape3); + ret.focalGradient = readFOCALGRADIENT(shapeNum); } if ((ret.fillStyleType == FILLSTYLE.REPEATING_BITMAP) @@ -1600,13 +1600,12 @@ public class SWFInputStream extends InputStream { FILLSTYLEARRAY ret = new FILLSTYLEARRAY(); int fillStyleCount = readUI8(); - - if (((shapeNum == 2) || (shapeNum == 3)) && (fillStyleCount == 0xff)) { + if (((shapeNum == 2) || (shapeNum == 3) || (shapeNum == 4/*?*/)) && (fillStyleCount == 0xff)) { fillStyleCount = readUI16(); } ret.fillStyles = new FILLSTYLE[fillStyleCount]; for (int i = 0; i < fillStyleCount; i++) { - ret.fillStyles[i] = readFILLSTYLE(shapeNum == 3); + ret.fillStyles[i] = readFILLSTYLE(shapeNum); } return ret; } @@ -1635,7 +1634,7 @@ public class SWFInputStream extends InputStream { * @return LINESTYLE2 value * @throws IOException */ - public LINESTYLE2 readLINESTYLE2(boolean inShape3) throws IOException { + public LINESTYLE2 readLINESTYLE2(int shapeNum) throws IOException { LINESTYLE2 ret = new LINESTYLE2(); ret.width = readUI16(); ret.startCapStyle = (int) readUB(2); @@ -1653,7 +1652,7 @@ public class SWFInputStream extends InputStream { if (!ret.hasFillFlag) { ret.color = readRGBA(); } else { - ret.fillType = readFILLSTYLE(inShape3); + ret.fillType = readFILLSTYLE(shapeNum); } return ret; } @@ -1678,7 +1677,7 @@ public class SWFInputStream extends InputStream { } else if (shapeNum == 4) { ret.lineStyles2 = new LINESTYLE2[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles2[i] = readLINESTYLE2(shapeNum == 3); + ret.lineStyles2[i] = readLINESTYLE2(shapeNum); } } return ret; @@ -2132,8 +2131,8 @@ public class SWFInputStream extends InputStream { */ public ZONEDATA readZONEDATA() throws IOException { ZONEDATA ret = new ZONEDATA(); - ret.alignmentCoordinate = readFLOAT16(); - ret.range = readFLOAT16(); + ret.alignmentCoordinate = readUI16(); + ret.range = readUI16(); return ret; } diff --git a/trunk/src/com/jpexs/asdec/SWFOutputStream.java b/trunk/src/com/jpexs/asdec/SWFOutputStream.java index 13579e7e1..539707359 100644 --- a/trunk/src/com/jpexs/asdec/SWFOutputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFOutputStream.java @@ -40,6 +40,12 @@ public class SWFOutputStream extends OutputStream { private int version; private long pos = 0; + public long getPos() { + return pos; + } + + + /** * Constructor * @@ -983,7 +989,7 @@ public class SWFOutputStream extends OutputStream { public void writeFILLSTYLE(FILLSTYLE value, int shapeNum) throws IOException { writeUI8(value.fillStyleType); if (value.fillStyleType == FILLSTYLE.SOLID) { - if (shapeNum == 3) { + if (shapeNum >= 3) { writeRGBA(value.colorA); } else if (shapeNum == 1 || shapeNum == 2) { writeRGB(value.color); @@ -1545,7 +1551,7 @@ public class SWFOutputStream extends OutputStream { * @throws IOException */ public void writeZONEDATA(ZONEDATA value) throws IOException { - writeFLOAT16(value.alignmentCoordinate); - writeFLOAT16(value.range); + writeUI16(value.alignmentCoordinate); + writeUI16(value.range); } } diff --git a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java index cf028b2fb..3a7950c97 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineBitsJPEG2Tag.java @@ -22,13 +22,13 @@ import java.io.IOException; public class DefineBitsJPEG2Tag extends Tag { - public int characterId; + public int characterID; public byte[] imageData; public DefineBitsJPEG2Tag(byte[] data, int version, long pos) throws IOException { super(21, data, pos); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); - characterId = sis.readUI16(); + characterID = sis.readUI16(); imageData = sis.readBytes(sis.available()); } diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java index 8a64c6dfd..1e3a95977 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButton2Tag.java @@ -177,8 +177,9 @@ public class DefineButton2Tag extends Tag implements Container, TagName { public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { - if (eat.assets.containsKey(buttonId)) { - name = ": " + eat.assets.get((Integer) buttonId); + int pos=eat.tags.indexOf(buttonId); + if (pos>-1) { + name = ": " + eat.names.get(pos); } } return "DefineButton2 (" + buttonId + name + ")"; diff --git a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java index 2001fd393..185ff386b 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineButtonTag.java @@ -110,8 +110,9 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName { public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { - if (eat.assets.containsKey(buttonId)) { - name = ": " + eat.assets.get((Integer) buttonId); + int pos=eat.tags.indexOf(buttonId); + if (pos>-1) { + name = ": " + eat.names.get(pos); } } return "DefineButton (" + buttonId + name + ")"; diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java b/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java index 12a3c3923..64ee2e37b 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFont3Tag.java @@ -18,6 +18,7 @@ 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; @@ -26,6 +27,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.Arrays; public class DefineFont3Tag extends Tag { @@ -75,15 +77,23 @@ public class DefineFont3Tag extends Tag { offsetTable[i] = sis.readUI16(); } } - long codeTableOffset = sis.readUI32(); + long codeTableOffset; + if (fontFlagsWideOffsets) { + codeTableOffset = sis.readUI32(); + } else { + codeTableOffset = sis.readUI16(); + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + CopyOutputStream cos = new CopyOutputStream(baos, new ByteArrayInputStream(Arrays.copyOfRange(data, (int) sis.getPos(), data.length - (int) sis.getPos()))); + SWFOutputStream scos = new SWFOutputStream(cos, 10); glyphShapeTable = new SHAPE[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { glyphShapeTable[i] = sis.readSHAPE(1); + scos.writeSHAPE(glyphShapeTable[i], 1); } - codeTable = new int[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { - if (fontFlagsWideOffsets) { + if (fontFlagsWideCodes) { codeTable[i] = sis.readUI16(); } else { codeTable[i] = sis.readUI8(); @@ -133,7 +143,7 @@ public class DefineFont3Tag extends Tag { sos.writeLANGCODE(languageCode); sos.writeUI8(fontName.getBytes().length); sos.write(fontName.getBytes()); - sos.write(numGlyphs); + sos.writeUI16(numGlyphs); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); SWFOutputStream sos2 = new SWFOutputStream(baos2, version); @@ -146,15 +156,25 @@ public class DefineFont3Tag extends Tag { } byte ba2[] = baos2.toByteArray(); ByteArrayOutputStream baos3 = new ByteArrayOutputStream(); - SWFOutputStream sos3 = new SWFOutputStream(baos2, version); + + CopyOutputStream cos = new CopyOutputStream(baos3, new ByteArrayInputStream(Arrays.copyOfRange(data, (int) sos.getPos() + ba2.length + (fontFlagsWideOffsets ? 4 : 2), (int) data.length - (int) sos.getPos() - ba2.length - (fontFlagsWideOffsets ? 4 : 2)))); + SWFOutputStream sos3 = new SWFOutputStream(cos, 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); + //codetableoffset 881 + if (fontFlagsWideOffsets) { + long offset = ba2.length + ba3.length + 4; + sos.writeUI32(offset); + } else { + long offset = ba2.length + ba3.length + 2; + sos.writeUI16((int)offset); + } sos.write(ba3); + for (int i = 0; i < numGlyphs; i++) { if (fontFlagsWideCodes) { sos.writeUI16(codeTable[i]); diff --git a/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java b/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java index e520928c1..b3feabdab 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineFontAlignZonesTag.java @@ -40,7 +40,8 @@ public class DefineFontAlignZonesTag extends Tag { sis.readUB(6); zoneTable = new ArrayList(); while (sis.available() > 0) { - zoneTable.add(sis.readZONERECORD()); + ZONERECORD zr=sis.readZONERECORD(); + zoneTable.add(zr); } } diff --git a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java index c6292f7e7..81fb81090 100644 --- a/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DefineSpriteTag.java @@ -105,8 +105,9 @@ public class DefineSpriteTag extends Tag implements Container, TagName { public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { - if (eat.assets.containsKey(spriteId)) { - name = ": " + eat.assets.get((Integer) spriteId); + int pos=eat.tags.indexOf(spriteId); + if (pos>-1) { + name = ": " + eat.names.get(pos); } } return "DefineSpriteTag (" + spriteId + name + ")"; diff --git a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java index 0f5734965..5bb0317c4 100644 --- a/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/asdec/tags/DoInitActionTag.java @@ -84,8 +84,9 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName { public String toString() { String name = ""; for (ExportAssetsTag eat : exportAssetsTags) { - if (eat.assets.containsKey(spriteId)) { - name = ": " + eat.assets.get((Integer) spriteId); + int pos=eat.tags.indexOf(spriteId); + if (pos>-1) { + name = ": " + eat.names.get(pos); } } return "DoInitAction (" + spriteId + name + ")"; diff --git a/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java b/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java index 07c066015..07a49bbd8 100644 --- a/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java +++ b/trunk/src/com/jpexs/asdec/tags/ExportAssetsTag.java @@ -22,7 +22,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * Makes portions of a SWF file available for import by other SWF files @@ -34,7 +36,8 @@ public class ExportAssetsTag extends Tag { /** * HashMap with assets */ - public HashMap assets; + public List tags; + public List names; /** * Constructor @@ -45,13 +48,15 @@ public class ExportAssetsTag extends Tag { */ public ExportAssetsTag(byte[] data, int version, long pos) throws IOException { super(56, data, pos); - assets = new HashMap(); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); int count = sis.readUI16(); + tags=new ArrayList(); + names=new ArrayList(); for (int i = 0; i < count; i++) { int characterId = sis.readUI16(); + tags.add(characterId); String name = sis.readString(); - assets.put(characterId, name); + names.add(name); } } @@ -67,10 +72,10 @@ public class ExportAssetsTag extends Tag { OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, version); try { - sos.writeUI16(assets.size()); - for (int characterId : assets.keySet()) { - sos.writeUI16(characterId); - sos.writeString(assets.get(characterId)); + sos.writeUI16(tags.size()); + for (int i = 0; i < tags.size(); i++) { + sos.writeUI16(tags.get(i)); + sos.writeString(names.get(i)); } } catch (IOException e) { } diff --git a/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java b/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java index 7643eb731..72a2f3ef8 100644 --- a/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java +++ b/trunk/src/com/jpexs/asdec/types/KERNINGRECORD.java @@ -26,4 +26,11 @@ public class KERNINGRECORD { public int fontKerningCode1; public int fontKerningCode2; public int fontKerningAdjustment; + + @Override + public String toString() { + return "[KERNINGRECORD fontKerningCode1="+fontKerningCode1+", fontKerningCode2="+fontKerningCode2+", fontKerningAdjustment="+fontKerningAdjustment+"]"; + } + + } diff --git a/trunk/src/com/jpexs/asdec/types/ZONEDATA.java b/trunk/src/com/jpexs/asdec/types/ZONEDATA.java index e67d85968..af8eefcc8 100644 --- a/trunk/src/com/jpexs/asdec/types/ZONEDATA.java +++ b/trunk/src/com/jpexs/asdec/types/ZONEDATA.java @@ -23,6 +23,13 @@ package com.jpexs.asdec.types; */ public class ZONEDATA { - public float alignmentCoordinate; - public float range; + public int alignmentCoordinate; + public int range; + + @Override + public String toString() { + return "[ZONEDATA alignmentCoordinate="+alignmentCoordinate+", range="+range+"]"; + } + + } diff --git a/trunk/src/com/jpexs/asdec/types/ZONERECORD.java b/trunk/src/com/jpexs/asdec/types/ZONERECORD.java index c0e336518..05f3f5b60 100644 --- a/trunk/src/com/jpexs/asdec/types/ZONERECORD.java +++ b/trunk/src/com/jpexs/asdec/types/ZONERECORD.java @@ -26,4 +26,17 @@ public class ZONERECORD { public ZONEDATA zonedata[]; public boolean zoneMaskX; public boolean zoneMaskY; + + @Override + public String toString() { + String ret="[ZONERECORD data:"; + for(int i=0;i0){ + ret+=", "; + } + ret+=zonedata[i]; + } + return ret+", zoneMaskX:"+zoneMaskX+", zoneMaskY:"+zoneMaskY+"]"; + } + }