Fixed some tags,

Image export stub
This commit is contained in:
Jindra Pet��k
2013-01-05 11:34:25 +01:00
parent 3b9ad85868
commit be6332c597
27 changed files with 570 additions and 81 deletions
+15 -7
View File
@@ -23,9 +23,7 @@ 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;
@@ -416,8 +414,8 @@ public class Main {
System.out.println(" ...opens SWF file with the decompiler GUI");
System.out.println(" 3) -proxy (-PXXX)");
System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. ");
System.out.println(" 4) -export (as|pcode) outdirectory infile");
System.out.println(" ...export infile actionscript to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument)");
System.out.println(" 4) -export (as|pcode|image) outdirectory infile");
System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument) or images");
System.out.println(" 5) -dumpSWF infile");
System.out.println(" ...dumps list of SWF tags to console");
System.out.println(" 6) -compress infile outfile");
@@ -478,8 +476,10 @@ public class Main {
String exportFormat = args[pos + 1];
if (!exportFormat.toLowerCase().equals("as")) {
if (!exportFormat.toLowerCase().equals("pcode")) {
System.err.println("Invalid export format:" + exportFormat);
badArguments();
if (!exportFormat.toLowerCase().equals("image")) {
System.err.println("Invalid export format:" + exportFormat);
badArguments();
}
}
}
File outDir = new File(args[pos + 2]);
@@ -492,6 +492,7 @@ public class Main {
boolean exportOK;
try {
printHeader();
dump_tags = true;
SWF exfile = new SWF(new FileInputStream(inFile));
exfile.addEventListener(new EventListener() {
public void handleEvent(String event, Object data) {
@@ -500,7 +501,14 @@ public class Main {
}
}
});
exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode"));
if (exportFormat.equals("image")) {
exfile.exportImages(outDir.getAbsolutePath());
exportOK = true;
} else if (exportFormat.equals("as") || exportFormat.equals("pcode")) {
exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode"));
} else {
exportOK = false;
}
} catch (Exception ex) {
exportOK = false;
System.err.print("FAIL: Exporting Failed on Exception - ");
+96 -16
View File
@@ -22,20 +22,31 @@ 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.DefineBitsLossless2Tag;
import com.jpexs.asdec.tags.DefineBitsLosslessTag;
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.ALPHABITMAPDATA;
import com.jpexs.asdec.types.ALPHACOLORMAPDATA;
import com.jpexs.asdec.types.BITMAPDATA;
import com.jpexs.asdec.types.COLORMAPDATA;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGB;
import com.jpexs.asdec.types.RGBA;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import javax.imageio.ImageIO;
/**
* Class representing SWF file
@@ -483,27 +494,27 @@ public class SWF {
}
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 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 DefineBitsJPEG3Tag) {
imageData = ((DefineBitsJPEG3Tag) t).imageData;
characterID = ((DefineBitsJPEG3Tag) t).characterID;
}
if(t instanceof DefineBitsJPEG4Tag){
imageData=((DefineBitsJPEG4Tag)t).imageData;
characterID=((DefineBitsJPEG4Tag)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));
fos = new FileOutputStream(outdir + File.separator + characterID + "." + getImageFormat(imageData));
if (hasErrorHeader(imageData)) {
fos.write(imageData,4,imageData.length-4);
fos.write(imageData, 4, imageData.length - 4);
} else {
fos.write(imageData);
}
@@ -517,6 +528,75 @@ public class SWF {
}
}
}
if (t instanceof DefineBitsLosslessTag) {
DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t;
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
COLORMAPDATA colorMapData = null;
BITMAPDATA bitmapData = null;
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = dbl.getColorMapData();
}
if ((dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB)) {
bitmapData = dbl.getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < dbl.bitmapHeight; y++) {
for (int x = 0; x < dbl.bitmapWidth; x++) {
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
RGB color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue));
}
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix15[pos].red * 8, bitmapData.bitmapPixelDataPix15[pos].green * 8, bitmapData.bitmapPixelDataPix15[pos].blue * 8));
}
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
g.setColor(new Color(bitmapData.bitmapPixelDataPix24[pos].red, bitmapData.bitmapPixelDataPix24[pos].green, bitmapData.bitmapPixelDataPix24[pos].blue));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
}
if (t instanceof DefineBitsLossless2Tag) {
DefineBitsLossless2Tag dbl = (DefineBitsLossless2Tag) t;
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
ALPHACOLORMAPDATA colorMapData = null;
ALPHABITMAPDATA bitmapData = null;
if (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED) {
colorMapData = dbl.getColorMapData();
}
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
bitmapData = dbl.getBitmapData();
}
int pos32aligned = 0;
int pos = 0;
for (int y = 0; y < dbl.bitmapHeight; y++) {
for (int x = 0; x < dbl.bitmapWidth; x++) {
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED)) {
RGBA color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
g.setColor(new Color(color.red, color.green, color.blue, color.alpha));
}
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
g.setColor(new Color(bitmapData.bitmapPixelData[pos].red, bitmapData.bitmapPixelData[pos].green, bitmapData.bitmapPixelData[pos].blue, bitmapData.bitmapPixelData[pos].alpha));
}
g.fillRect(x, y, 1, 1);
pos32aligned++;
pos++;
}
while ((pos32aligned % 4 != 0)) {
pos32aligned++;
}
}
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
}
if ((jtt != null) && (t instanceof DefineBitsTag)) {
DefineBitsTag dbt = (DefineBitsTag) t;
FileOutputStream fos = null;
@@ -1166,6 +1166,21 @@ public class SWFInputStream extends InputStream {
return ret;
}
/**
* Reads one ARGB value from the stream
*
* @return ARGB value
* @throws IOException
*/
public ARGB readARGB() throws IOException {
ARGB ret = new ARGB();
ret.alpha = readUI8();
ret.red = readUI8();
ret.green = readUI8();
ret.blue = readUI8();
return ret;
}
/**
* Reads one RGB value from the stream
*
@@ -2136,6 +2151,145 @@ public class SWFInputStream extends InputStream {
return ret;
}
/**
* Reads one PIX15 value from the stream
*
* @return PIX15 value
* @throws IOException
*/
public PIX15 readPIX15() throws IOException {
PIX15 ret = new PIX15();
readUB(1);
ret.red = (int) readUB(5);
ret.green = (int) readUB(5);
ret.blue = (int) readUB(5);
return ret;
}
/**
* Reads one PIX24 value from the stream
*
* @return PIX24 value
* @throws IOException
*/
public PIX24 readPIX24() throws IOException {
PIX24 ret = new PIX24();
readUI8();
ret.red = readUI8();
ret.green = readUI8();
ret.blue = readUI8();
return ret;
}
/**
* Reads one COLORMAPDATA value from the stream
*
* @return COLORMAPDATA value
* @throws IOException
*/
public COLORMAPDATA readCOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException {
COLORMAPDATA ret = new COLORMAPDATA();
ret.colorTableRGB = new RGB[colorTableSize + 1];
for (int i = 0; i < colorTableSize + 1; i++) {
ret.colorTableRGB[i] = readRGB();
}
int dataLen = 0;
for (int y = 0; y < bitmapHeight; y++) {
int x = 0;
for (; x < bitmapWidth; x++) {
dataLen++;
}
while ((x % 4) != 0) {
dataLen++;
x++;
}
}
ret.colorMapPixelData = readBytes(dataLen);
return ret;
}
/**
* Reads one BITMAPDATA value from the stream
*
* @return COLORMAPDATA value
* @throws IOException
*/
public BITMAPDATA readBITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException {
BITMAPDATA ret = new BITMAPDATA();
List<PIX15> pix15 = new ArrayList<PIX15>();
List<PIX24> pix24 = new ArrayList<PIX24>();
int dataLen = 0;
for (int y = 0; y < bitmapHeight; y++) {
int x = 0;
for (; x < bitmapWidth; x++) {
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
dataLen += 2;
pix15.add(readPIX15());
}
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
dataLen += 4;
pix24.add(readPIX24());
}
dataLen++;
}
while ((x % 4) != 0) {
dataLen++;
readUI8();
x++;
}
}
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
ret.bitmapPixelDataPix15 = pix15.toArray(new PIX15[pix15.size()]);
} else if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
ret.bitmapPixelDataPix24 = pix24.toArray(new PIX24[pix24.size()]);
}
return ret;
}
/**
* Reads one BITMAPDATA value from the stream
*
* @return COLORMAPDATA value
* @throws IOException
*/
public ALPHABITMAPDATA readALPHABITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException {
ALPHABITMAPDATA ret = new ALPHABITMAPDATA();
ret.bitmapPixelData = new ARGB[bitmapWidth * bitmapHeight];
for (int y = 0; y < bitmapHeight; y++) {
for (int x = 0; x < bitmapWidth; x++) {
ret.bitmapPixelData[y * bitmapWidth + x] = readARGB();
}
}
return ret;
}
/**
* Reads one ALPHACOLORMAPDATA value from the stream
*
* @return ALPHACOLORMAPDATA value
* @throws IOException
*/
public ALPHACOLORMAPDATA readALPHACOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException {
ALPHACOLORMAPDATA ret = new ALPHACOLORMAPDATA();
ret.colorTableRGB = new RGBA[colorTableSize + 1];
for (int i = 0; i < colorTableSize + 1; i++) {
ret.colorTableRGB[i] = readRGBA();
}
int dataLen = 0;
for (int y = 0; y < bitmapHeight; y++) {
int x = 0;
for (; x < bitmapWidth; x++) {
dataLen++;
}
while ((x % 4) != 0) {
dataLen++;
x++;
}
}
ret.colorMapPixelData = readBytes(dataLen);
return ret;
}
@Override
public int available() throws IOException {
return is.available();
+15 -13
View File
@@ -44,8 +44,6 @@ public class SWFOutputStream extends OutputStream {
return pos;
}
/**
* Constructor
*
@@ -322,6 +320,20 @@ public class SWFOutputStream extends OutputStream {
writeSB(nBits, longVal);
}
private static int bitCount(int value) {
value = Math.abs(value);
int nBits = 0;
while ((value & ~0xF) != 0) {
value >>= 4;
nBits += 4;
}
while (value != 0) {
value >>= 1;
nBits++;
}
return nBits;
}
/**
* Writes RECT value to the stream
*
@@ -390,17 +402,7 @@ public class SWFOutputStream extends OutputStream {
* @return
*/
public static int getNeededBits(int number, int bits) {
number = Math.abs(number);
int val = 1;
for (int x = 1; val <= number && !(bits > 32); x <<= 1) {
val = val | x;
bits++;
}
if (bits > 32) {
assert false : ("minBits " + bits + " must not exceed 32");
}
return bits;
return bitCount(number) + bits;
}
/**
-1
View File
@@ -300,7 +300,6 @@ public class ABC {
}
aos.writeU30(constants.constant_multiname.length);
//System.out.println("Writing "+constants.constant_multiname.length+" multinames");
for (int i = 1; i < constants.constant_multiname.length; i++) {
aos.writeMultiname(constants.constant_multiname[i]);
}
@@ -2298,11 +2298,9 @@ public class AVM2Code {
ins.ignored = true;
ip++;
} else if (ins.definition instanceof IfTrueIns) {
System.out.println("iftrue found");
boolean val = myStack.pop();
if (val) {
code.get(ip).definition = new JumpIns();
System.out.println("changed to jump");
ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]);
} else {
code.get(ip).ignored = true;
@@ -36,10 +36,6 @@ public class GetScopeObjectIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
int index = ins.operands[0];
/* System.out.println("Getting scope object"+index+":");
for(TreeItem ti:scopeStack){
System.out.println(ti.toString(constants));
}*/
stack.push(scopeStack.get(index));
}
@@ -18,10 +18,13 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.types.ALPHABITMAPDATA;
import com.jpexs.asdec.types.ALPHACOLORMAPDATA;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.InflaterInputStream;
public class DefineBitsLossless2Tag extends Tag {
@@ -42,11 +45,42 @@ public class DefineBitsLossless2Tag extends Tag {
bitmapFormat = sis.readUI8();
bitmapWidth = sis.readUI16();
bitmapHeight = sis.readUI16();
if (bitmapFormat == FORMAT_15BIT_RGB) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8();
}
zlibBitmapData = sis.readBytes(sis.available());
}
private ALPHACOLORMAPDATA colorMapData;
private ALPHABITMAPDATA bitmapData;
private boolean decompressed = false;
public ALPHACOLORMAPDATA getColorMapData() {
if (!decompressed) {
uncompressData();
}
return colorMapData;
}
public ALPHABITMAPDATA getBitmapData() {
if (!decompressed) {
uncompressData();
}
return bitmapData;
}
private void uncompressData() {
try {
SWFInputStream sis = new SWFInputStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData)), 10);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight);
}
if ((bitmapFormat == FORMAT_15BIT_RGB) || (bitmapFormat == FORMAT_24BIT_RGB)) {
bitmapData = sis.readALPHABITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight);
}
} catch (IOException ex) {
}
decompressed = true;
}
/**
* Gets data bytes
@@ -64,7 +98,7 @@ public class DefineBitsLossless2Tag extends Tag {
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_15BIT_RGB) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
sos.write(zlibBitmapData);
@@ -18,10 +18,13 @@ package com.jpexs.asdec.tags;
import com.jpexs.asdec.SWFInputStream;
import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.types.BITMAPDATA;
import com.jpexs.asdec.types.COLORMAPDATA;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.InflaterInputStream;
public class DefineBitsLosslessTag extends Tag {
@@ -34,6 +37,37 @@ public class DefineBitsLosslessTag extends Tag {
public static final int FORMAT_8BIT_COLORMAPPED = 3;
public static final int FORMAT_15BIT_RGB = 4;
public static final int FORMAT_24BIT_RGB = 5;
private COLORMAPDATA colorMapData;
private BITMAPDATA bitmapData;
private boolean decompressed = false;
public COLORMAPDATA getColorMapData() {
if (!decompressed) {
uncompressData();
}
return colorMapData;
}
public BITMAPDATA getBitmapData() {
if (!decompressed) {
uncompressData();
}
return bitmapData;
}
private void uncompressData() {
try {
SWFInputStream sis = new SWFInputStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData)), 10);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight);
}
if ((bitmapFormat == FORMAT_15BIT_RGB) || (bitmapFormat == FORMAT_24BIT_RGB)) {
bitmapData = sis.readBITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight);
}
} catch (IOException ex) {
}
decompressed = true;
}
public DefineBitsLosslessTag(byte[] data, int version, long pos) throws IOException {
super(20, data, pos);
@@ -42,7 +76,7 @@ public class DefineBitsLosslessTag extends Tag {
bitmapFormat = sis.readUI8();
bitmapWidth = sis.readUI16();
bitmapHeight = sis.readUI16();
if (bitmapFormat == FORMAT_15BIT_RGB) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8();
}
zlibBitmapData = sis.readBytes(sis.available());
@@ -64,7 +98,7 @@ public class DefineBitsLosslessTag extends Tag {
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_15BIT_RGB) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
sos.write(zlibBitmapData);
@@ -177,8 +177,8 @@ public class DefineButton2Tag extends Tag implements Container, TagName {
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos=eat.tags.indexOf(buttonId);
if (pos>-1) {
int pos = eat.tags.indexOf(buttonId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
@@ -110,8 +110,8 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName {
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos=eat.tags.indexOf(buttonId);
if (pos>-1) {
int pos = eat.tags.indexOf(buttonId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
@@ -18,7 +18,6 @@ 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;
@@ -27,7 +26,6 @@ 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 {
@@ -83,13 +81,9 @@ public class DefineFont3Tag extends Tag {
} 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++) {
@@ -157,8 +151,7 @@ public class DefineFont3Tag extends Tag {
byte ba2[] = baos2.toByteArray();
ByteArrayOutputStream baos3 = new ByteArrayOutputStream();
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);
SWFOutputStream sos3 = new SWFOutputStream(baos3, version);
for (int i = 0; i < numGlyphs; i++) {
sos3.writeSHAPE(glyphShapeTable[i], 1);
}
@@ -170,7 +163,7 @@ public class DefineFont3Tag extends Tag {
sos.writeUI32(offset);
} else {
long offset = ba2.length + ba3.length + 2;
sos.writeUI16((int)offset);
sos.writeUI16((int) offset);
}
sos.write(ba3);
@@ -40,7 +40,7 @@ public class DefineFontAlignZonesTag extends Tag {
sis.readUB(6);
zoneTable = new ArrayList<ZONERECORD>();
while (sis.available() > 0) {
ZONERECORD zr=sis.readZONERECORD();
ZONERECORD zr = sis.readZONERECORD();
zoneTable.add(zr);
}
}
@@ -105,8 +105,8 @@ public class DefineSpriteTag extends Tag implements Container, TagName {
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos=eat.tags.indexOf(spriteId);
if (pos>-1) {
int pos = eat.tags.indexOf(spriteId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
@@ -84,8 +84,8 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
public String toString() {
String name = "";
for (ExportAssetsTag eat : exportAssetsTags) {
int pos=eat.tags.indexOf(spriteId);
if (pos>-1) {
int pos = eat.tags.indexOf(spriteId);
if (pos > -1) {
name = ": " + eat.names.get(pos);
}
}
@@ -23,7 +23,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
@@ -50,8 +49,8 @@ public class ExportAssetsTag extends Tag {
super(56, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int count = sis.readUI16();
tags=new ArrayList<Integer>();
names=new ArrayList<String>();
tags = new ArrayList<Integer>();
names = new ArrayList<String>();
for (int i = 0; i < count; i++) {
int characterId = sis.readUI16();
tags.add(characterId);
@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 32-bit alpha, red, green and blue value
*
* @author JPEXS
*/
public class ALPHABITMAPDATA {
public ARGB bitmapPixelData[];
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 32-bit alpha, red, green and blue value
*
* @author JPEXS
*/
public class ALPHACOLORMAPDATA {
public RGBA colorTableRGB[];
public byte colorMapPixelData[];
}
@@ -39,4 +39,9 @@ public class ARGB {
* Blue color value
*/
public int blue;
@Override
public String toString() {
return "[ARGB a=" + alpha + ",r=" + red + ",g=" + green + ",b=" + blue + "]";
}
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 32-bit alpha, red, green and blue value
*
* @author JPEXS
*/
public class BITMAPDATA {
public PIX15 bitmapPixelDataPix15[];
public PIX24 bitmapPixelDataPix24[];
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 32-bit alpha, red, green and blue value
*
* @author JPEXS
*/
public class COLORMAPDATA {
public RGB colorTableRGB[];
public byte colorMapPixelData[];
}
@@ -29,8 +29,6 @@ public class KERNINGRECORD {
@Override
public String toString() {
return "[KERNINGRECORD fontKerningCode1="+fontKerningCode1+", fontKerningCode2="+fontKerningCode2+", fontKerningAdjustment="+fontKerningAdjustment+"]";
return "[KERNINGRECORD fontKerningCode1=" + fontKerningCode1 + ", fontKerningCode2=" + fontKerningCode2 + ", fontKerningAdjustment=" + fontKerningAdjustment + "]";
}
}
@@ -0,0 +1,38 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 15-bit red, green and blue value
*
* @author JPEXS
*/
public class PIX15 {
/**
* Red color value
*/
public int red;
/**
* Green color value
*/
public int green;
/**
* Blue color value
*/
public int blue;
}
@@ -0,0 +1,38 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types;
/**
* Represents 15-bit red, green and blue value
*
* @author JPEXS
*/
public class PIX24 {
/**
* Red color value
*/
public int red;
/**
* Green color value
*/
public int green;
/**
* Blue color value
*/
public int blue;
}
@@ -39,4 +39,9 @@ public class RECT {
* Y maximum position for rectangle in twips
*/
public int Ymax;
@Override
public String toString() {
return "[RECT x=" + Xmin + "-" + Xmax + ", y=" + Ymin + "-" + Ymax + "]";
}
}
@@ -28,8 +28,6 @@ public class ZONEDATA {
@Override
public String toString() {
return "[ZONEDATA alignmentCoordinate="+alignmentCoordinate+", range="+range+"]";
return "[ZONEDATA alignmentCoordinate=" + alignmentCoordinate + ", range=" + range + "]";
}
}
@@ -29,14 +29,13 @@ public class ZONERECORD {
@Override
public String toString() {
String ret="[ZONERECORD data:";
for(int i=0;i<zonedata.length;i++){
if(i>0){
ret+=", ";
String ret = "[ZONERECORD data:";
for (int i = 0; i < zonedata.length; i++) {
if (i > 0) {
ret += ", ";
}
ret+=zonedata[i];
ret += zonedata[i];
}
return ret+", zoneMaskX:"+zoneMaskX+", zoneMaskY:"+zoneMaskY+"]";
return ret + ", zoneMaskX:" + zoneMaskX + ", zoneMaskY:" + zoneMaskY + "]";
}
}