keep remaining data, when tag is not fully parsed

This commit is contained in:
honfika@gmail.com
2015-06-14 14:10:37 +02:00
parent ba61e8af04
commit d00acbd7df
87 changed files with 1068 additions and 1737 deletions

View File

@@ -1484,6 +1484,10 @@ public class SWFInputStream implements AutoCloseable {
ret = new UnknownTag(swf, tag.getId(), data);
}
}
if (sis.available() > 0) {
ret.remainingData = sis.readBytesEx(sis.available(), "remaining");
}
} catch (IOException ex) {
logger.log(Level.SEVERE, "Error during tag reading. SWF: " + swf.getShortFileName() + " ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex);
ret = new TagStub(swf, tag.getId(), "ErrorTag", data, null);

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -96,25 +94,18 @@ public class CSMTextSettingsTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(textID);
sos.writeUB(2, useFlashType);
sos.writeUB(3, gridFit);
sos.writeUB(3, reserved);
sos.writeFLOAT(thickness); //F32 = FLOAT
sos.writeFLOAT(sharpness); //F32 = FLOAT
sos.writeUI8(reserved2);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(textID);
sos.writeUB(2, useFlashType);
sos.writeUB(3, gridFit);
sos.writeUB(3, reserved);
sos.writeFLOAT(thickness); //F32 = FLOAT
sos.writeFLOAT(sharpness); //F32 = FLOAT
sos.writeUI8(reserved2);
}
@Override

View File

@@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -69,18 +67,11 @@ public class DebugIDTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(debugId);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.write(debugId);
}
}

View File

@@ -28,10 +28,8 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
/**
@@ -93,21 +91,14 @@ public class DefineBinaryDataTag extends CharacterTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(tag);
sos.writeUI32(reserved);
sos.write(binaryData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(tag);
sos.writeUI32(reserved);
sos.write(binaryData);
}
@Override

View File

@@ -33,7 +33,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -86,18 +85,16 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
imageData = sis.readByteRangeEx(sis.available(), "imageData");
}
/**
* Gets data bytes
*
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.write(imageData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.write(imageData);
}
@Override

View File

@@ -34,7 +34,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -90,22 +89,15 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.getLength());
sos.write(imageData);
sos.write(bitmapAlphaData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeUI32(imageData.getLength());
sos.write(imageData);
sos.write(bitmapAlphaData);
}
private byte[] createEmptyImage() {

View File

@@ -34,7 +34,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -94,23 +93,16 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.getLength());
sos.writeUI16(deblockParam);
sos.write(imageData);
sos.write(bitmapAlphaData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeUI32(imageData.getLength());
sos.writeUI16(deblockParam);
sos.write(imageData);
sos.write(bitmapAlphaData);
}
private byte[] createEmptyImage() {

View File

@@ -39,7 +39,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.InflaterInputStream;
@@ -117,26 +116,19 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
sos.write(zlibBitmapData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
return baos.toByteArray();
sos.write(zlibBitmapData);
}
private byte[] createEmptyImage() {

View File

@@ -39,7 +39,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.InflaterInputStream;
@@ -119,26 +118,19 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
sos.write(zlibBitmapData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
sos.writeUI16(bitmapWidth);
sos.writeUI16(bitmapHeight);
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
sos.writeUI8(bitmapColorTableSize);
}
return baos.toByteArray();
sos.write(zlibBitmapData);
}
private byte[] createEmptyImage() {

View File

@@ -32,7 +32,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -75,20 +74,13 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.write(jpegData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.write(jpegData);
}
@Override

View File

@@ -19,8 +19,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
@@ -37,10 +35,8 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Cache;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -128,39 +124,27 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
ByteArrayInputStream bais = new ByteArrayInputStream(getOriginalData());
os = new CopyOutputStream(os, bais);
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeUB(7, reserved);
sos.writeUB(1, trackAsMenu ? 1 : 0);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(buttonId);
sos.writeUB(7, reserved);
sos.writeUB(1, trackAsMenu ? 1 : 0);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try (SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion())) {
sos2.writeBUTTONRECORDList(characters, true);
}
byte[] brdata = baos2.toByteArray();
if ((actions == null) || (actions.isEmpty())) {
sos.writeUI16(0);
} else {
sos.writeUI16(2 + brdata.length);
}
sos.write(brdata);
sos.writeBUTTONCONDACTIONList(actions);
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try (SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion())) {
sos2.writeBUTTONRECORDList(characters, true);
}
return baos.toByteArray();
byte[] brdata = baos2.toByteArray();
if ((actions == null) || (actions.isEmpty())) {
sos.writeUI16(0);
} else {
sos.writeUI16(2 + brdata.length);
}
sos.write(brdata);
sos.writeBUTTONCONDACTIONList(actions);
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CXFORM;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -74,20 +72,13 @@ public class DefineButtonCxformTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeCXFORM(buttonColorTransform);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(buttonId);
sos.writeCXFORM(buttonColorTransform);
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -106,35 +104,28 @@ public class DefineButtonSoundTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
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) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
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);
}
return baos.toByteArray();
}
@Override

View File

@@ -20,11 +20,9 @@ import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.ActionListReader;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
@@ -44,10 +42,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -125,26 +120,15 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeBUTTONRECORDList(characters, false);
sos.write(getActionBytes());
//sos.write(Action.actionsToBytes(actions, true, version));
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(buttonId);
sos.writeBUTTONRECORDList(characters, false);
sos.write(getActionBytes());
//sos.write(Action.actionsToBytes(actions, true, version));
}
@Override

View File

@@ -59,9 +59,7 @@ import com.jpexs.helpers.utf8.Utf8Helper;
import java.awt.Color;
import java.awt.Font;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
@@ -245,63 +243,55 @@ public class DefineEditTextTag extends TextTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
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) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
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);
}
return baos.toByteArray();
}
@Override

View File

@@ -197,82 +197,75 @@ public class DefineFont2Tag extends FontTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
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);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
int numGlyphs = glyphShapeTable.size();
sos.writeUI16(numGlyphs);
public void getData(SWFOutputStream sos) throws IOException {
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);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
int numGlyphs = glyphShapeTable.size();
sos.writeUI16(numGlyphs);
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add((glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
}
byte[] baGlyphShapes = baosGlyphShapes.toByteArray();
for (Long offset : offsetTable) {
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) (long) offset);
}
}
if (numGlyphs > 0) {
long offset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + baGlyphShapes.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) offset);
}
sos.write(baGlyphShapes);
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
} else {
sos.writeUI8(codeTable.get(i));
}
}
}
if (fontFlagsHasLayout) {
sos.writeSI16(fontAscent);
sos.writeSI16(fontDescent);
sos.writeSI16(fontLeading);
for (int i = 0; i < numGlyphs; i++) {
sos.writeSI16(fontAdvanceTable.get(i));
}
for (int i = 0; i < numGlyphs; i++) {
sos.writeRECT(fontBoundsTable.get(i));
}
sos.writeUI16(fontKerningTable.size());
for (int k = 0; k < fontKerningTable.size(); k++) {
sos.writeKERNINGRECORD(fontKerningTable.get(k), fontFlagsWideCodes);
}
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add((glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
}
byte[] baGlyphShapes = baosGlyphShapes.toByteArray();
for (Long offset : offsetTable) {
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) (long) offset);
}
}
if (numGlyphs > 0) {
long offset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + baGlyphShapes.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) offset);
}
sos.write(baGlyphShapes);
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
} else {
sos.writeUI8(codeTable.get(i));
}
}
}
if (fontFlagsHasLayout) {
sos.writeSI16(fontAscent);
sos.writeSI16(fontDescent);
sos.writeSI16(fontLeading);
for (int i = 0; i < numGlyphs; i++) {
sos.writeSI16(fontAdvanceTable.get(i));
}
for (int i = 0; i < numGlyphs; i++) {
sos.writeRECT(fontBoundsTable.get(i));
}
sos.writeUI16(fontKerningTable.size());
for (int k = 0; k < fontKerningTable.size(); k++) {
sos.writeKERNINGRECORD(fontKerningTable.get(k), fontFlagsWideCodes);
}
}
return baos.toByteArray();
}
@Override

View File

@@ -19,8 +19,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.FontHelper;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -34,10 +32,8 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.awt.Font;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -191,95 +187,84 @@ public class DefineFont3Tag extends FontTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
if (Configuration.debugCopy.get()) {
sos = new SWFOutputStream(new CopyOutputStream(sos, new ByteArrayInputStream(getOriginalData())), getVersion());
public void getData(SWFOutputStream sos) throws IOException {
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
int numGlyphs = glyphShapeTable.size();
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add(sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
}
try {
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
int numGlyphs = glyphShapeTable.size();
byte[] baGlyphShapes = baosGlyphShapes.toByteArray();
if (!fontFlagsWideOffsets && numGlyphs > 0) {
// Set wide offsets when necessary
long maxOffset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * 2 + baGlyphShapes.length;
if (maxOffset > 65535) {
fontFlagsWideOffsets = true;
}
}
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);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUI16(numGlyphs);
for (long offset : offsetTable) {
long offset2 = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + offset;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset2);
} else {
sos.writeUI16((int) offset2);
}
}
if (numGlyphs > 0) {
long offset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + baGlyphShapes.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) offset);
}
sos.write(baGlyphShapes);
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add(sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
}
byte[] baGlyphShapes = baosGlyphShapes.toByteArray();
if (!fontFlagsWideOffsets && numGlyphs > 0) {
// Set wide offsets when necessary
long maxOffset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * 2 + baGlyphShapes.length;
if (maxOffset > 65535) {
fontFlagsWideOffsets = true;
}
}
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);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUI16(numGlyphs);
for (long offset : offsetTable) {
long offset2 = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + offset;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset2);
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
} else {
sos.writeUI16((int) offset2);
sos.writeUI8(codeTable.get(i));
}
}
if (numGlyphs > 0) {
long offset = (glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + baGlyphShapes.length;
if (fontFlagsWideOffsets) {
sos.writeUI32(offset);
} else {
sos.writeUI16((int) offset);
}
sos.write(baGlyphShapes);
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
sos.writeUI16(codeTable.get(i));
} else {
sos.writeUI8(codeTable.get(i));
}
}
}
if (fontFlagsHasLayout) {
sos.writeSI16(fontAscent);
sos.writeSI16(fontDescent);
sos.writeSI16(fontLeading);
for (int i = 0; i < numGlyphs; i++) {
sos.writeSI16(fontAdvanceTable.get(i));
}
for (int i = 0; i < numGlyphs; i++) {
sos.writeRECT(fontBoundsTable.get(i));
}
sos.writeUI16(fontKerningTable.size());
for (int k = 0; k < fontKerningTable.size(); k++) {
sos.writeKERNINGRECORD(fontKerningTable.get(k), fontFlagsWideCodes);
}
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
if (fontFlagsHasLayout) {
sos.writeSI16(fontAscent);
sos.writeSI16(fontDescent);
sos.writeSI16(fontLeading);
for (int i = 0; i < numGlyphs; i++) {
sos.writeSI16(fontAdvanceTable.get(i));
}
for (int i = 0; i < numGlyphs; i++) {
sos.writeRECT(fontBoundsTable.get(i));
}
sos.writeUI16(fontKerningTable.size());
for (int k = 0; k < fontKerningTable.size(); k++) {
sos.writeKERNINGRECORD(fontKerningTable.get(k), fontFlagsWideCodes);
}
}
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -86,25 +84,18 @@ public class DefineFont4Tag extends CharacterTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
sos.writeUB(5, reserved);
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) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontID);
sos.writeUB(5, reserved);
sos.writeUB(1, fontFlagsHasFontData ? 1 : 0);
sos.writeUB(1, fontFlagsItalic ? 1 : 0);
sos.writeUB(1, fontFlagsBold ? 1 : 0);
sos.writeString(fontName);
sos.write(fontData);
}
@Override

View File

@@ -26,9 +26,7 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -85,24 +83,17 @@ public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
sos.writeUB(2, CSMTableHint);
sos.writeUB(6, reserved);
for (ZONERECORD z : zoneTable) {
sos.writeZONERECORD(z);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontID);
sos.writeUB(2, CSMTableHint);
sos.writeUB(6, reserved);
for (ZONERECORD z : zoneTable) {
sos.writeZONERECORD(z);
}
return baos.toByteArray();
}
@Override

View File

@@ -26,9 +26,7 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -119,33 +117,26 @@ public class DefineFontInfo2Tag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUB(2, 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);
sos.writeLANGCODE(languageCode);
for (int c : codeTable) {
sos.writeUI16(c);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontID);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUB(2, 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);
sos.writeLANGCODE(languageCode);
for (int c : codeTable) {
sos.writeUI16(c);
}
return baos.toByteArray();
}
@Override

View File

@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -117,36 +115,29 @@ public class DefineFontInfoTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUB(2, 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);
}
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontId);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
sos.writeUI8(fontNameBytes.length);
sos.write(fontNameBytes);
sos.writeUB(2, 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) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
}
@Override

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -70,21 +68,14 @@ public class DefineFontNameTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
sos.writeString(fontName);
sos.writeString(fontCopyright);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontId);
sos.writeString(fontName);
sos.writeString(fontCopyright);
}
@Override

View File

@@ -29,7 +29,6 @@ import com.jpexs.helpers.ByteArrayRange;
import java.awt.Font;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -102,30 +101,23 @@ public class DefineFontTag extends FontTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
List<Integer> offsetTable = new ArrayList<>();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
for (SHAPE shape : glyphShapeTable) {
offsetTable.add(glyphShapeTable.size() * 2 + (int) sos2.getPos());
sos2.writeSHAPE(shape, 1);
}
for (int offset : offsetTable) {
sos.writeUI16(offset);
}
sos.write(baos2.toByteArray());
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontId);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
List<Integer> offsetTable = new ArrayList<>();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
for (SHAPE shape : glyphShapeTable) {
offsetTable.add(glyphShapeTable.size() * 2 + (int) sos2.getPos());
sos2.writeSHAPE(shape, 1);
}
return baos.toByteArray();
for (int offset : offsetTable) {
sos.writeUI16(offset);
}
sos.write(baos2.toByteArray());
}
@Override

View File

@@ -32,7 +32,6 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -108,35 +107,28 @@ public class DefineMorphShape2Tag extends MorphShapeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
sos.writeRECT(endBounds);
sos.writeRECT(startEdgeBounds);
sos.writeRECT(endEdgeBounds);
sos.writeUB(6, reserved);
sos.writeUB(1, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(1, usesScalingStrokes ? 1 : 0);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 2);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 2);
sos2.writeSHAPE(startEdges, 2);
byte[] ba2 = baos2.toByteArray();
sos.writeUI32(ba2.length);
sos.write(ba2);
sos.writeSHAPE(endEdges, 2);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
sos.writeRECT(endBounds);
sos.writeRECT(startEdgeBounds);
sos.writeRECT(endEdgeBounds);
sos.writeUB(6, reserved);
sos.writeUB(1, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(1, usesScalingStrokes ? 1 : 0);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 2);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 2);
sos2.writeSHAPE(startEdges, 2);
byte[] ba2 = baos2.toByteArray();
sos.writeUI32(ba2.length);
sos.write(ba2);
sos.writeSHAPE(endEdges, 2);
}
@Override

View File

@@ -29,7 +29,6 @@ import com.jpexs.decompiler.flash.types.SHAPE;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -86,30 +85,23 @@ public class DefineMorphShapeTag extends MorphShapeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
sos.writeRECT(endBounds);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 1);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 1);
sos2.writeSHAPE(startEdges, 1);
byte[] ba2 = baos2.toByteArray();
sos.writeUI32(ba2.length);
sos.write(ba2);
sos.writeSHAPE(endEdges, 1);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
sos.writeRECT(endBounds);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 1);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 1);
sos2.writeSHAPE(startEdges, 1);
byte[] ba2 = baos2.toByteArray();
sos.writeUI32(ba2.length);
sos.write(ba2);
sos.writeSHAPE(endEdges, 1);
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -67,20 +65,13 @@ public class DefineScalingGridTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(splitter);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeRECT(splitter);
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -103,29 +101,22 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
int sceneCount = sceneOffsets.length;
sos.writeEncodedU32(sceneCount);
for (int i = 0; i < sceneCount; i++) {
sos.writeEncodedU32(sceneOffsets[i]);
sos.writeString(sceneNames[i]);
}
int frameLabelCount = frameNums.length;
sos.writeEncodedU32(frameLabelCount);
for (int i = 0; i < frameLabelCount; i++) {
sos.writeEncodedU32(frameNums[i]);
sos.writeString(frameNames[i]);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
int sceneCount = sceneOffsets.length;
sos.writeEncodedU32(sceneCount);
for (int i = 0; i < sceneCount; i++) {
sos.writeEncodedU32(sceneOffsets[i]);
sos.writeString(sceneNames[i]);
}
int frameLabelCount = frameNums.length;
sos.writeEncodedU32(frameLabelCount);
for (int i = 0; i < frameLabelCount; i++) {
sos.writeEncodedU32(frameNums[i]);
sos.writeString(frameNames[i]);
}
return baos.toByteArray();
}
}

View File

@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
@@ -61,26 +60,21 @@ public class DefineShape2Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
sis.skipBytes(sis.available());
}
}
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
}
@Override

View File

@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
@@ -61,26 +60,21 @@ public class DefineShape3Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
sis.skipBytes(sis.available());
}
}
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
}
@Override

View File

@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
@@ -82,31 +81,26 @@ public class DefineShape4Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
sis.skipBytes(sis.available());
}
}
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeRECT(edgeBounds);
sos.writeUB(5, reserved);
sos.writeUB(1, usesFillWindingRule ? 1 : 0);
sos.writeUB(1, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(1, usesScalingStrokes ? 1 : 0);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeRECT(edgeBounds);
sos.writeUB(5, reserved);
sos.writeUB(1, usesFillWindingRule ? 1 : 0);
sos.writeUB(1, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(1, usesScalingStrokes ? 1 : 0);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
}
@Override

View File

@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
@@ -61,26 +60,21 @@ public class DefineShapeTag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
sis.skipBytes(sis.available());
}
}
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
}
@Override

View File

@@ -33,7 +33,6 @@ import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -107,26 +106,18 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundId);
sos.writeUB(4, soundFormat);
sos.writeUB(2, soundRate);
sos.writeUB(1, soundSize ? 1 : 0);
sos.writeUB(1, soundType ? 1 : 0);
sos.writeUI32(soundSampleCount);
sos.write(soundData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(soundId);
sos.writeUB(4, soundFormat);
sos.writeUB(2, soundRate);
sos.writeUB(1, soundSize ? 1 : 0);
sos.writeUB(1, soundType ? 1 : 0);
sos.writeUI32(soundSampleCount);
sos.write(soundData);
}
@Override

View File

@@ -19,8 +19,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -41,10 +39,7 @@ import com.jpexs.helpers.Cache;
import com.jpexs.helpers.SerializableImage;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
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.HashSet;
@@ -131,28 +126,17 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(spriteId);
sos.writeUI16(frameCount);
sos.writeTags(subTags);
if (hasEndTag) {
sos.writeUI16(0);
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(spriteId);
sos.writeUI16(frameCount);
sos.writeTags(subTags);
if (hasEndTag) {
sos.writeUI16(0);
}
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
}
@Override

View File

@@ -26,9 +26,7 @@ import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
/**
@@ -110,26 +108,19 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI16(numFrames);
sos.writeUI16(width);
sos.writeUI16(height);
sos.writeUB(4, reserved);
sos.writeUB(3, videoFlagsDeblocking);
sos.writeUB(1, videoFlagsSmoothing ? 1 : 0);
sos.writeUI8(codecID);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeUI16(numFrames);
sos.writeUI16(width);
sos.writeUI16(height);
sos.writeUB(4, reserved);
sos.writeUB(3, videoFlagsDeblocking);
sos.writeUB(1, videoFlagsSmoothing ? 1 : 0);
sos.writeUI8(codecID);
}
@Override

View File

@@ -21,18 +21,13 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.SWFField;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Defines a series of ActionScript 3 bytecodes to be executed
@@ -103,25 +98,14 @@ public class DoABC2Tag extends Tag implements ABCContainerTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
OutputStream os = bos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) {
sos.writeUI32(flags);
sos.writeString(name);
abc.saveToStream(sos);
}
return bos.toByteArray();
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI32(flags);
sos.writeString(name);
abc.saveToStream(sos);
}
@Override

View File

@@ -21,16 +21,11 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.SWFField;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Defines a series of ActionScript 3 bytecodes to be executed
@@ -83,23 +78,12 @@ public class DoABCTag extends Tag implements ABCContainerTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
OutputStream os = bos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) {
abc.saveToStream(sos);
}
return bos.toByteArray();
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
public void getData(SWFOutputStream sos) throws IOException {
abc.saveToStream(sos);
}
@Override

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.ActionListReader;
@@ -93,11 +94,12 @@ public class DoActionTag extends Tag implements ASMSource {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
return getActionBytes();
public void getData(SWFOutputStream sos) throws IOException {
sos.write(getActionBytes());
}
/**

View File

@@ -32,7 +32,6 @@ import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -92,21 +91,14 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(spriteId);
sos.write(getActionBytes());
//sos.write(Action.actionsToBytes(actions, true, version));
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(spriteId);
sos.write(getActionBytes());
//sos.write(Action.actionsToBytes(actions, true, version));
}
/**

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Marks the file is not importable for editing
@@ -78,20 +76,12 @@ public class EnableDebugger2Tag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(reserved);
sos.writeString(passwordHash);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(reserved);
sos.writeString(passwordHash);
}
}

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Marks the file is not importable for editing
@@ -70,20 +68,13 @@ public class EnableDebuggerTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
if (passwordHash != null) {
sos.writeString(passwordHash);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
if (passwordHash != null) {
sos.writeString(passwordHash);
}
return baos.toByteArray();
}
}

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.types.annotations.Optional;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Enable flash profiling information
@@ -80,21 +78,14 @@ public class EnableTelemetryTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(16, reserved);
if (passwordHash != null) {
sos.write(passwordHash);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(16, reserved);
if (passwordHash != null) {
sos.write(passwordHash);
}
return baos.toByteArray();
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -60,10 +61,9 @@ public class EndTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
return new byte[0];
public void getData(SWFOutputStream sos) {
}
}

View File

@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -93,22 +91,15 @@ public class ExportAssetsTag extends SymbolClassTypeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
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) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(tags.size());
for (int i = 0; i < tags.size(); i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
return baos.toByteArray();
}
}

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class FileAttributesTag extends Tag {
@@ -87,26 +85,19 @@ public class FileAttributesTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, reserved1 ? 1 : 0); //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(1, noCrossDomainCache ? 1 : 0);
sos.writeUB(1, reserved2 ? 1 : 0); //reserved
sos.writeUB(1, useNetwork ? 1 : 0);
sos.writeUB(24, reserved3); //reserved
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(1, reserved1 ? 1 : 0); //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(1, noCrossDomainCache ? 1 : 0);
sos.writeUB(1, reserved2 ? 1 : 0); //reserved
sos.writeUB(1, useNetwork ? 1 : 0);
sos.writeUB(24, reserved3); //reserved
}
}

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class FrameLabelTag extends Tag {
@@ -62,22 +60,15 @@ public class FrameLabelTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(name);
if (namedAnchor) {
sos.writeUI8(1);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeString(name);
if (namedAnchor) {
sos.writeUI8(1);
}
return baos.toByteArray();
}
public String getLabelName() {

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -54,10 +55,9 @@ public class FreeAllTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
return new byte[0];
public void getData(SWFOutputStream sos) {
}
}

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -66,19 +64,12 @@ public class FreeCharacterTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
}
@Override

View File

@@ -22,15 +22,12 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.ImportTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -115,32 +112,25 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(url);
sos.writeUI8(downloadNow);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeString(url);
sos.writeUI8(downloadNow);
if (hasDigest == 1 && sha1 != null && sha1.matches("[0-9a-fA-F]{40}")) {
sos.writeUI8(1);
sos.write(Helper.hexToByteArray(sha1));
} else {
sos.writeUI8(0);
}
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) {
throw new Error("This should never happen.", e);
if (hasDigest == 1 && sha1 != null && sha1.matches("[0-9a-fA-F]{40}")) {
sos.writeUI8(1);
sos.write(Helper.hexToByteArray(sha1));
} else {
sos.writeUI8(0);
}
sos.writeUI16(tags.size());
for (int i = 0; i < tags.size(); i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
return baos.toByteArray();
}
@Override

View File

@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -98,24 +96,17 @@ public class ImportAssetsTag extends Tag implements ImportTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(url);
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) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeString(url);
sos.writeUI16(tags.size());
for (int i = 0; i < tags.size(); i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
return baos.toByteArray();
}
@Override

View File

@@ -21,9 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class JPEGTablesTag extends Tag {
@@ -57,18 +55,11 @@ public class JPEGTablesTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(jpegData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.write(jpegData);
}
}

View File

@@ -21,9 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.Multiline;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class MetadataTag extends Tag {
@@ -60,18 +58,11 @@ public class MetadataTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(xmlMetadata);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeString(xmlMetadata);
}
}

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -74,20 +72,13 @@ public class NameCharacterTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeString(name);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeString(name);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -54,10 +55,9 @@ public class PathsArePostScriptTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
return new byte[0];
public void getData(SWFOutputStream sos) {
}
}

View File

@@ -19,8 +19,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -35,10 +33,7 @@ import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.FILTER;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -224,52 +219,41 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUI16(depth);
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUI16(depth);
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
return baos.toByteArray();
}
@Override

View File

@@ -20,8 +20,6 @@ import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -38,10 +36,7 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.FILTER;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -326,81 +321,70 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUB(1, reserved ? 1 : 0);
sos.writeUB(1, placeFlagOpaqueBackground ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasVisible ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasImage ? 1 : 0);
sos.writeUB(1, placeFlagHasClassName ? 1 : 0);
sos.writeUB(1, placeFlagHasCacheAsBitmap ? 1 : 0);
sos.writeUB(1, placeFlagHasBlendMode ? 1 : 0);
sos.writeUB(1, placeFlagHasFilterList ? 1 : 0);
sos.writeUI16(depth);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUB(1, reserved ? 1 : 0);
sos.writeUB(1, placeFlagOpaqueBackground ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasVisible ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasImage ? 1 : 0);
sos.writeUB(1, placeFlagHasClassName ? 1 : 0);
sos.writeUB(1, placeFlagHasCacheAsBitmap ? 1 : 0);
sos.writeUB(1, placeFlagHasBlendMode ? 1 : 0);
sos.writeUB(1, placeFlagHasFilterList ? 1 : 0);
sos.writeUI16(depth);
if (placeFlagHasClassName) {
sos.writeString(className);
}
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasFilterList) {
sos.writeFILTERLIST(surfaceFilterList);
}
if (placeFlagHasBlendMode) {
sos.writeUI8(blendMode);
}
if (placeFlagHasCacheAsBitmap) {
if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
}
if (placeFlagHasVisible) {
sos.writeUI8(visible);
}
if (placeFlagOpaqueBackground) {
sos.writeRGBA(backgroundColor);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
if (placeFlagHasClassName) {
sos.writeString(className);
}
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasFilterList) {
sos.writeFILTERLIST(surfaceFilterList);
}
if (placeFlagHasBlendMode) {
sos.writeUI8(blendMode);
}
if (placeFlagHasCacheAsBitmap) {
if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
}
if (placeFlagHasVisible) {
sos.writeUI8(visible);
}
if (placeFlagOpaqueBackground) {
sos.writeRGBA(backgroundColor);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
return baos.toByteArray();
}
@Override

View File

@@ -20,8 +20,6 @@ import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -38,10 +36,7 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.FILTER;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -329,81 +324,70 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUB(1, reserved ? 1 : 0);
sos.writeUB(1, placeFlagOpaqueBackground ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasVisible ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasImage ? 1 : 0);
sos.writeUB(1, placeFlagHasClassName ? 1 : 0);
sos.writeUB(1, placeFlagHasCacheAsBitmap ? 1 : 0);
sos.writeUB(1, placeFlagHasBlendMode ? 1 : 0);
sos.writeUB(1, placeFlagHasFilterList ? 1 : 0);
sos.writeUI16(depth);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
sos.writeUB(1, placeFlagHasName ? 1 : 0);
sos.writeUB(1, placeFlagHasRatio ? 1 : 0);
sos.writeUB(1, placeFlagHasColorTransform ? 1 : 0);
sos.writeUB(1, placeFlagHasMatrix ? 1 : 0);
sos.writeUB(1, placeFlagHasCharacter ? 1 : 0);
sos.writeUB(1, placeFlagMove ? 1 : 0);
sos.writeUB(1, reserved ? 1 : 0);
sos.writeUB(1, placeFlagOpaqueBackground ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasVisible ? 1 : 0); //SWF11
sos.writeUB(1, placeFlagHasImage ? 1 : 0);
sos.writeUB(1, placeFlagHasClassName ? 1 : 0);
sos.writeUB(1, placeFlagHasCacheAsBitmap ? 1 : 0);
sos.writeUB(1, placeFlagHasBlendMode ? 1 : 0);
sos.writeUB(1, placeFlagHasFilterList ? 1 : 0);
sos.writeUI16(depth);
if (placeFlagHasClassName) {
sos.writeString(className);
}
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasFilterList) {
sos.writeFILTERLIST(surfaceFilterList);
}
if (placeFlagHasBlendMode) {
sos.writeUI8(blendMode);
}
if (placeFlagHasCacheAsBitmap) {
if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
}
if (placeFlagHasVisible) {
sos.writeUI8(visible);
}
if (placeFlagOpaqueBackground) {
sos.writeRGBA(backgroundColor);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
sos.close();
} catch (IOException e) {
throw new Error("This should never happen.", e);
if (placeFlagHasClassName) {
sos.writeString(className);
}
if (placeFlagHasCharacter) {
sos.writeUI16(characterId);
}
if (placeFlagHasMatrix) {
sos.writeMatrix(matrix);
}
if (placeFlagHasColorTransform) {
sos.writeCXFORMWITHALPHA(colorTransform);
}
if (placeFlagHasRatio) {
sos.writeUI16(ratio);
}
if (placeFlagHasName) {
sos.writeString(name);
}
if (placeFlagHasClipDepth) {
sos.writeUI16(clipDepth);
}
if (placeFlagHasFilterList) {
sos.writeFILTERLIST(surfaceFilterList);
}
if (placeFlagHasBlendMode) {
sos.writeUI8(blendMode);
}
if (placeFlagHasCacheAsBitmap) {
if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
}
if (placeFlagHasVisible) {
sos.writeUI8(visible);
}
if (placeFlagOpaqueBackground) {
sos.writeRGBA(backgroundColor);
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
}
return baos.toByteArray();
}
@Override

View File

@@ -30,9 +30,7 @@ import com.jpexs.decompiler.flash.types.annotations.Optional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.FILTER;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Set;
@@ -90,24 +88,17 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(depth);
sos.writeMatrix(matrix);
if (colorTransform != null) {
sos.writeCXFORM(colorTransform);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeUI16(depth);
sos.writeMatrix(matrix);
if (colorTransform != null) {
sos.writeCXFORM(colorTransform);
}
return baos.toByteArray();
}
/**

View File

@@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class ProductInfoTag extends Tag {
@@ -98,23 +96,21 @@ public class ProductInfoTag extends Tag {
compilationDateHigh = sis.readUI32("compilationDateHigh");
}
/**
* Gets data bytes
*
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(productID);
sos.writeUI32(edition);
sos.writeUI8(majorVersion);
sos.writeUI8(minorVersion);
sos.writeUI32(buildLow);
sos.writeUI32(buildHigh);
sos.writeUI32(compilationDateLow);
sos.writeUI32(compilationDateHigh);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI32(productID);
sos.writeUI32(edition);
sos.writeUI8(majorVersion);
sos.writeUI8(minorVersion);
sos.writeUI32(buildLow);
sos.writeUI32(buildHigh);
sos.writeUI32(compilationDateLow);
sos.writeUI32(compilationDateHigh);
}
}

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Marks the file is not importable for editing
@@ -74,20 +72,13 @@ public class ProtectTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
if (!"".equals(passwordHash)) {
sos.writeString(passwordHash);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
if (!"".equals(passwordHash)) {
sos.writeString(passwordHash);
}
return baos.toByteArray();
}
}

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -69,19 +67,12 @@ public class RemoveObject2Tag extends RemoveTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(depth);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(depth);
}
@Override

View File

@@ -24,9 +24,7 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Removes the specified character
@@ -82,20 +80,13 @@ public class RemoveObjectTag extends RemoveTag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(depth);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeUI16(depth);
}
@Override

View File

@@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class ScriptLimitsTag extends Tag {
@@ -61,19 +59,12 @@ public class ScriptLimitsTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(maxRecursionDepth);
sos.writeUI16(scriptTimeoutSeconds);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(maxRecursionDepth);
sos.writeUI16(scriptTimeoutSeconds);
}
}

View File

@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class SetBackgroundColorTag extends Tag {
@@ -57,15 +56,14 @@ public class SetBackgroundColorTag extends Tag {
backgroundColor = sis.readRGB("backgroundColor");
}
/**
* Gets data bytes
*
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeRGB(backgroundColor);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeRGB(backgroundColor);
}
}

View File

@@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Sets the index of an object within the tab order.
@@ -79,19 +77,12 @@ public class SetTabIndexTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(depth);
sos.writeUI16(tabIndex);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(depth);
sos.writeUI16(tabIndex);
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.util.ArrayList;
import java.util.List;
@@ -78,11 +79,10 @@ public class ShowFrameTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
return new byte[0];
public void getData(SWFOutputStream sos) {
}
public static boolean isNestedTagType(int tagTypeId) {

View File

@@ -21,9 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -70,18 +68,11 @@ public class SoundStreamBlockTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(streamSoundData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.write(streamSoundData);
}
}

View File

@@ -29,10 +29,8 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.sound.SoundExportFormat;
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -118,30 +116,23 @@ public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
sos.writeUB(1, playBackSoundSize ? 1 : 0);
sos.writeUB(1, playBackSoundType ? 1 : 0);
sos.writeUB(4, streamSoundCompression);
sos.writeUB(2, streamSoundRate);
sos.writeUB(1, streamSoundSize ? 1 : 0);
sos.writeUB(1, streamSoundType ? 1 : 0);
sos.writeUI16(streamSoundSampleCount);
if (streamSoundCompression == 2) {
sos.writeSI16(latencySeek);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
sos.writeUB(1, playBackSoundSize ? 1 : 0);
sos.writeUB(1, playBackSoundType ? 1 : 0);
sos.writeUB(4, streamSoundCompression);
sos.writeUB(2, streamSoundRate);
sos.writeUB(1, streamSoundSize ? 1 : 0);
sos.writeUB(1, streamSoundType ? 1 : 0);
sos.writeUI16(streamSoundSampleCount);
if (streamSoundCompression == 2) {
sos.writeSI16(latencySeek);
}
return baos.toByteArray();
}
@Override

View File

@@ -29,10 +29,8 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.sound.SoundExportFormat;
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -117,30 +115,23 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
sos.writeUB(1, playBackSoundSize ? 1 : 0);
sos.writeUB(1, playBackSoundType ? 1 : 0);
sos.writeUB(4, streamSoundCompression);
sos.writeUB(2, streamSoundRate);
sos.writeUB(1, streamSoundSize ? 1 : 0);
sos.writeUB(1, streamSoundType ? 1 : 0);
sos.writeUI16(streamSoundSampleCount);
if (streamSoundCompression == 2) {
sos.writeSI16(latencySeek);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
sos.writeUB(1, playBackSoundSize ? 1 : 0);
sos.writeUB(1, playBackSoundType ? 1 : 0);
sos.writeUB(4, streamSoundCompression);
sos.writeUB(2, streamSoundRate);
sos.writeUB(1, streamSoundSize ? 1 : 0);
sos.writeUB(1, streamSoundType ? 1 : 0);
sos.writeUI16(streamSoundSampleCount);
if (streamSoundCompression == 2) {
sos.writeSI16(latencySeek);
}
return baos.toByteArray();
}
@Override

View File

@@ -21,9 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -71,19 +69,12 @@ public class StartSound2Tag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(soundClassName);
sos.writeSOUNDINFO(soundInfo);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeString(soundClassName);
sos.writeSOUNDINFO(soundInfo);
}
}

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -74,19 +72,12 @@ public class StartSoundTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundId);
sos.writeSOUNDINFO(soundInfo);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(soundId);
sos.writeSOUNDINFO(soundInfo);
}
}

View File

@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -78,23 +76,16 @@ public class SymbolClassTag extends SymbolClassTypeTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
int numSymbols = tags.size();
sos.writeUI16(numSymbols);
for (int i = 0; i < numSymbols; i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
int numSymbols = tags.size();
sos.writeUI16(numSymbols);
for (int i = 0; i < numSymbols; i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
return baos.toByteArray();
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -54,10 +55,9 @@ public class SyncFrameTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
return new byte[0];
public void getData(SWFOutputStream sos) {
}
}

View File

@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
@@ -39,8 +41,10 @@ import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
@@ -88,6 +92,9 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
private final HashSet<TagChangedListener> listeners = new HashSet<>();
@Internal
public byte[] remainingData;
/**
* Constructor
*
@@ -349,12 +356,12 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
return swf.version;
}
protected byte[] getHeader(byte[] data) {
protected byte[] getHeader(int dataLength) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SWFOutputStream sos = new SWFOutputStream(baos, swf.version);
int tagLength = data.length;
int tagLength = dataLength;
int tagID = getId();
int tagIDLength = (tagID << 6);
if ((tagLength <= 62) && (!forceWriteAsLong)) {
@@ -395,7 +402,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
public void writeTag(SWFOutputStream sos) throws IOException {
if (isModified()) {
byte[] newData = getData();
byte[] newHeaderData = getHeader(newData);
byte[] newHeaderData = getHeader(newData.length);
sos.write(newHeaderData);
sos.write(newData);
} else {
@@ -439,12 +446,44 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
return getName();
}
/**
* Gets data bytes
*
* @param sos SWF output stream
* @throws java.io.IOException
*/
public abstract void getData(SWFOutputStream sos) throws IOException;
/**
* Gets data bytes
*
* @return Bytes of data
*/
public abstract byte[] getData();
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
// todo: honfika: why only the following tags?
if (this instanceof DefineSpriteTag
|| this instanceof DefineButtonTag || this instanceof DefineButton2Tag
|| this instanceof DefineFont3Tag
|| this instanceof DoABCTag || this instanceof DoABC2Tag
|| this instanceof PlaceObject2Tag || this instanceof PlaceObject3Tag || this instanceof PlaceObject4Tag) {
os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData()));
}
}
try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) {
getData(sos);
if (remainingData != null) {
sos.write(remainingData);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
}
public final ByteArrayRange getOriginalRange() {
return originalRange;
@@ -521,7 +560,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
public void createOriginalData() {
byte[] data = getData();
byte[] headerData = getHeader(data);
byte[] headerData = getHeader(data.length);
byte[] tagData = new byte[data.length + headerData.length];
System.arraycopy(headerData, 0, tagData, 0, headerData.length);
System.arraycopy(data, 0, tagData, headerData.length, data.length);

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -51,10 +52,10 @@ public class TagStub extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
*/
@Override
public byte[] getData() {
public void getData(SWFOutputStream sos) {
throw new Error("TagStub.getData call is not supported.");
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
@@ -38,11 +39,12 @@ public class UnknownTag extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
return getOriginalRange().getRangeData();
public void getData(SWFOutputStream sos) throws IOException {
sos.write(getOriginalRange().getRangeData());
}
@Override

View File

@@ -23,9 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -78,21 +76,14 @@ public class VideoFrameTag extends Tag implements CharacterIdTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(streamID);
sos.writeUI16(frameNum);
sos.write(videoData);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(streamID);
sos.writeUI16(frameNum);
sos.write(videoData);
}
@Override

View File

@@ -43,9 +43,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.SerializableImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
@@ -95,42 +93,35 @@ public abstract class StaticTextTag extends TextTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeRECT(textBounds);
sos.writeMatrix(textMatrix);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterID);
sos.writeRECT(textBounds);
sos.writeMatrix(textMatrix);
int glyphBits = 0;
int advanceBits = 0;
for (TEXTRECORD tr : textRecords) {
for (GLYPHENTRY ge : tr.glyphEntries) {
glyphBits = SWFOutputStream.enlargeBitCountU(glyphBits, ge.glyphIndex);
advanceBits = SWFOutputStream.enlargeBitCountS(advanceBits, ge.glyphAdvance);
}
int glyphBits = 0;
int advanceBits = 0;
for (TEXTRECORD tr : textRecords) {
for (GLYPHENTRY ge : tr.glyphEntries) {
glyphBits = SWFOutputStream.enlargeBitCountU(glyphBits, ge.glyphIndex);
advanceBits = SWFOutputStream.enlargeBitCountS(advanceBits, ge.glyphAdvance);
}
if (Configuration.debugCopy.get()) {
glyphBits = Math.max(glyphBits, this.glyphBits);
advanceBits = Math.max(advanceBits, this.advanceBits);
}
sos.writeUI8(glyphBits);
sos.writeUI8(advanceBits);
for (TEXTRECORD tr : textRecords) {
sos.writeTEXTRECORD(tr, getTextNum(), glyphBits, advanceBits);
}
sos.writeUI8(0);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
if (Configuration.debugCopy.get()) {
glyphBits = Math.max(glyphBits, this.glyphBits);
advanceBits = Math.max(advanceBits, this.advanceBits);
}
sos.writeUI8(glyphBits);
sos.writeUI8(advanceBits);
for (TEXTRECORD tr : textRecords) {
sos.writeTEXTRECORD(tr, getTextNum(), glyphBits, advanceBits);
}
sos.writeUI8(0);
}
@Override

View File

@@ -40,9 +40,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.MemoryInputStream;
import java.awt.Font;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -66,22 +64,15 @@ public final class DefineCompactedFont extends FontTag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
for (FontType ft : fonts) {
ft.write(new GFxOutputStream(sos));
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(fontId);
for (FontType ft : fonts) {
ft.write(new GFxOutputStream(sos));
}
return baos.toByteArray();
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -52,24 +50,17 @@ public class DefineExternalGradient extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(gradientId);
sos.writeUI16(bitmapsFormat);
sos.writeUI16(gradientSize);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(gradientId);
sos.writeUI16(bitmapsFormat);
sos.writeUI16(gradientSize);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -54,25 +52,18 @@ public class DefineExternalImage extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(bitmapFormat);
sos.writeUI16(targetWidth);
sos.writeUI16(targetHeight);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeUI16(bitmapFormat);
sos.writeUI16(targetWidth);
sos.writeUI16(targetHeight);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -58,31 +56,24 @@ public class DefineExternalImage2 extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(characterId);
sos.writeUI16(bitmapFormat);
sos.writeUI16(targetWidth);
sos.writeUI16(targetHeight);
byte[] exportNameBytes = exportName.getBytes();
sos.writeUI8(exportNameBytes.length);
sos.write(exportNameBytes);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
if (extraData != null) {
sos.write(extraData);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI32(characterId);
sos.writeUI16(bitmapFormat);
sos.writeUI16(targetWidth);
sos.writeUI16(targetHeight);
byte[] exportNameBytes = exportName.getBytes();
sos.writeUI8(exportNameBytes.length);
sos.write(exportNameBytes);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
if (extraData != null) {
sos.write(extraData);
}
return baos.toByteArray();
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -58,31 +56,24 @@ public class DefineExternalSound extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(soundFormat);
sos.writeUI16(bits);
sos.writeUI16(channels);
sos.writeUI32(sampleRate);
sos.writeUI32(sampleCount);
sos.writeUI32(seekSample);
byte[] exportNameBytes = exportName.getBytes();
sos.writeUI8(exportNameBytes.length);
sos.write(exportNameBytes);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeUI16(soundFormat);
sos.writeUI16(bits);
sos.writeUI16(channels);
sos.writeUI32(sampleRate);
sos.writeUI32(sampleCount);
sos.writeUI32(seekSample);
byte[] exportNameBytes = exportName.getBytes();
sos.writeUI8(exportNameBytes.length);
sos.write(exportNameBytes);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -58,29 +56,22 @@ public class DefineExternalStreamSound extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundFormat);
sos.writeUI16(bits);
sos.writeUI16(channels);
sos.writeUI32(sampleRate);
sos.writeUI32(sampleCount);
sos.writeUI32(seekSample);
sos.writeUI32(startFrame);
sos.writeUI32(lastFrame);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(soundFormat);
sos.writeUI16(bits);
sos.writeUI16(channels);
sos.writeUI32(sampleRate);
sos.writeUI32(sampleCount);
sos.writeUI32(seekSample);
sos.writeUI32(startFrame);
sos.writeUI32(lastFrame);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -40,22 +38,15 @@ public class DefineGradientMap extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(indices.length);
for (int i = 0; i < indices.length; i++) {
sos.writeUI16(indices[i]);
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(indices.length);
for (int i = 0; i < indices.length; i++) {
sos.writeUI16(indices[i]);
}
return baos.toByteArray();
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -50,24 +48,17 @@ public class DefineSubImage extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(imageCharacterId);
sos.writeUI16(x1);
sos.writeUI16(y1);
sos.writeUI16(x2);
sos.writeUI16(y2);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(characterId);
sos.writeUI16(imageCharacterId);
sos.writeUI16(x1);
sos.writeUI16(y1);
sos.writeUI16(x2);
sos.writeUI16(y2);
}
/**

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -64,34 +62,27 @@ public class ExporterInfo extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
try {
sos.writeUI16(this.version);
if (this.version >= 0x10a) {
sos.writeUI32(flags);
}
sos.writeUI16(bitmapFormat);
sos.writeUI8(prefix.length);
sos.write(prefix);
byte[] swfNameBytes = swfName.getBytes();
sos.writeUI8(swfNameBytes.length);
sos.write(swfNameBytes);
if (codeOffsets != null) {
sos.writeUI16(codeOffsets.size());
for (long l : codeOffsets) {
sos.writeUI32(l);
}
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI16(this.version);
if (this.version >= 0x10a) {
sos.writeUI32(flags);
}
sos.writeUI16(bitmapFormat);
sos.writeUI8(prefix.length);
sos.write(prefix);
byte[] swfNameBytes = swfName.getBytes();
sos.writeUI8(swfNameBytes.length);
sos.write(swfNameBytes);
if (codeOffsets != null) {
sos.writeUI16(codeOffsets.size());
for (long l : codeOffsets) {
sos.writeUI32(l);
}
}
return baos.toByteArray();
}
/**

View File

@@ -25,9 +25,7 @@ import com.jpexs.decompiler.flash.types.gfx.GFxOutputStream;
import com.jpexs.decompiler.flash.types.gfx.TEXGLYPH;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.MemoryInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -67,35 +65,28 @@ public class FontTextureInfo extends Tag {
/**
* Gets data bytes
*
* @return Bytes of data
* @param sos SWF output stream
* @throws java.io.IOException
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(textureID);
sos.writeUI16(textureFormat);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
sos.writeUI16(textureWidth);
sos.writeUI16(textureHeight);
sos.writeUI8(padPixels);
sos.writeUI16(nominalGlyphSz);
sos.writeUI16(texGlyphs.length);
for (int i = 0; i < texGlyphs.length; i++) {
texGlyphs[i].write(new GFxOutputStream(sos));
}
sos.writeUI16(fonts.length);
for (int i = 0; i < fonts.length; i++) {
fonts[i].write(new GFxOutputStream(sos));
}
} catch (IOException e) {
throw new Error("This should never happen.", e);
public void getData(SWFOutputStream sos) throws IOException {
sos.writeUI32(textureID);
sos.writeUI16(textureFormat);
byte[] fileNameBytes = fileName.getBytes();
sos.writeUI8(fileNameBytes.length);
sos.write(fileNameBytes);
sos.writeUI16(textureWidth);
sos.writeUI16(textureHeight);
sos.writeUI8(padPixels);
sos.writeUI16(nominalGlyphSz);
sos.writeUI16(texGlyphs.length);
for (int i = 0; i < texGlyphs.length; i++) {
texGlyphs[i].write(new GFxOutputStream(sos));
}
sos.writeUI16(fonts.length);
for (int i = 0; i < fonts.length; i++) {
fonts[i].write(new GFxOutputStream(sos));
}
return baos.toByteArray();
}
/**