mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 07:14:49 +00:00
Merge origin/master
This commit is contained in:
@@ -69,7 +69,6 @@ import com.jpexs.decompiler.flash.exporters.script.AS3ScriptExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
@@ -1555,15 +1554,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
if (ch instanceof ImageTag) {
|
||||
ImageTag image = (ImageTag) ch;
|
||||
ImageFormat format = image.getImageFormat();
|
||||
InputStream imageStream = image.getImageData();
|
||||
byte[] imageData;
|
||||
if (imageStream != null) {
|
||||
imageData = Helper.readStream(image.getImageData());
|
||||
} else {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(image.getImage().getBufferedImage(), format, baos);
|
||||
imageData = baos.toByteArray();
|
||||
}
|
||||
byte[] imageData = Helper.readStream(image.getImageData());
|
||||
String base64ImgData = Helper.byteArrayToBase64String(imageData);
|
||||
fos.write(Utf8Helper.getBytes("var imageObj" + c + " = document.createElement(\"img\");\r\nimageObj" + c + ".src=\"data:image/" + format + ";base64," + base64ImgData + "\";\r\n"));
|
||||
}
|
||||
|
||||
@@ -28,8 +28,11 @@ import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -88,7 +91,9 @@ public class ImageExporter {
|
||||
|
||||
new RetryTask(() -> {
|
||||
if (ffileFormat == originalFormat) {
|
||||
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
fos.write(Helper.readStream(imageTag.getImageData()));
|
||||
}
|
||||
} else if (ffileFormat == ImageFormat.BMP) {
|
||||
BMPFile.saveBitmap(imageTag.getImage().getBufferedImage(), file);
|
||||
} else {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundTag;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundExportFormat;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -83,12 +84,12 @@ public class SoundExporter {
|
||||
String ext = "wav";
|
||||
SoundFormat fmt = st.getSoundFormat();
|
||||
switch (fmt.getNativeExportFormat()) {
|
||||
case SoundFormat.EXPORT_MP3:
|
||||
case MP3:
|
||||
if (settings.mode.hasMP3()) {
|
||||
ext = "mp3";
|
||||
}
|
||||
break;
|
||||
case SoundFormat.EXPORT_FLV:
|
||||
case FLV:
|
||||
if (settings.mode.hasFlv()) {
|
||||
ext = "flv";
|
||||
}
|
||||
@@ -125,14 +126,14 @@ public class SoundExporter {
|
||||
|
||||
public void exportSound(OutputStream fos, SoundTag st, SoundExportMode mode) throws IOException {
|
||||
SoundFormat fmt = st.getSoundFormat();
|
||||
int nativeFormat = fmt.getNativeExportFormat();
|
||||
SoundExportFormat nativeFormat = fmt.getNativeExportFormat();
|
||||
|
||||
if (nativeFormat == SoundFormat.EXPORT_MP3 && mode.hasMP3()) {
|
||||
if (nativeFormat == SoundExportFormat.MP3 && mode.hasMP3()) {
|
||||
List<ByteArrayRange> datas = st.getRawSoundData();
|
||||
for (ByteArrayRange data : datas) {
|
||||
fos.write(data.getRangeData());
|
||||
}
|
||||
} else if ((nativeFormat == SoundFormat.EXPORT_FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) {
|
||||
} else if ((nativeFormat == SoundExportFormat.FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) {
|
||||
if (st instanceof DefineSoundTag) {
|
||||
FLVOutputStream flv = new FLVOutputStream(fos);
|
||||
flv.writeHeader(true, false);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -33,8 +32,6 @@ import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
@@ -116,15 +113,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
lastPatternId++;
|
||||
String patternId = "PatternID_" + lastPatternId;
|
||||
ImageFormat format = image.getImageFormat();
|
||||
InputStream imageStream = image.getImageData();
|
||||
byte[] imageData;
|
||||
if (imageStream != null) {
|
||||
imageData = Helper.readStream(image.getImageData());
|
||||
} else {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(img.getBufferedImage(), format, baos);
|
||||
imageData = baos.toByteArray();
|
||||
}
|
||||
byte[] imageData = Helper.readStream(image.getImageData());
|
||||
String base64ImgData = Helper.byteArrayToBase64String(imageData);
|
||||
path.setAttribute("style", "fill:url(#" + patternId + ")");
|
||||
Element pattern = exporter.createElement("pattern");
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters.shape;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -33,8 +32,6 @@ import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
@@ -114,15 +111,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
String patternId = "PatternID_";
|
||||
patternId += lastPatternId;
|
||||
ImageFormat format = image.getImageFormat();
|
||||
InputStream imageStream = image.getImageData();
|
||||
byte[] imageData;
|
||||
if (imageStream != null) {
|
||||
imageData = Helper.readStream(image.getImageData());
|
||||
} else {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(img.getBufferedImage(), format, baos);
|
||||
imageData = baos.toByteArray();
|
||||
}
|
||||
byte[] imageData = Helper.readStream(image.getImageData());
|
||||
String base64ImgData = Helper.byteArrayToBase64String(imageData);
|
||||
path.setAttribute("style", "fill:url(#" + patternId + ")");
|
||||
Element pattern = exporter.createElement("pattern");
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
public InputStream getOriginalImageData() {
|
||||
int errorLength = hasErrorHeader(imageData) ? 4 : 0;
|
||||
return new ByteArrayInputStream(imageData.getArray(), imageData.getPos() + errorLength, imageData.getLength() - errorLength);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
|
||||
return cachedImage;
|
||||
}
|
||||
try {
|
||||
BufferedImage image = ImageHelper.read(getImageData());
|
||||
BufferedImage image = ImageHelper.read(getOriginalImageData());
|
||||
if (image == null) {
|
||||
Logger.getLogger(DefineBitsJPEG2Tag.class.getName()).log(Level.SEVERE, "Failed to load image");
|
||||
return null;
|
||||
|
||||
@@ -160,18 +160,13 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
|
||||
public InputStream getOriginalImageData() {
|
||||
if (bitmapAlphaData.getLength() == 0) { //No alpha, then its JPEG
|
||||
int errorLength = hasErrorHeader(imageData) ? 4 : 0;
|
||||
return new ByteArrayInputStream(imageData.getArray(), imageData.getPos() + errorLength, imageData.getLength() - errorLength);
|
||||
}
|
||||
|
||||
//Make PNG
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(getImage().getBufferedImage(), ImageFormat.PNG, baos);
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -165,16 +165,12 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
|
||||
public InputStream getOriginalImageData() {
|
||||
if (bitmapAlphaData.getLength() == 0) { //No alpha, then its JPEG
|
||||
return new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength());
|
||||
}
|
||||
//Make PNG
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(getImage().getBufferedImage(), ImageFormat.PNG, baos);
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -228,7 +228,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
public InputStream getOriginalImageData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
public InputStream getOriginalImageData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -102,15 +103,7 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getImageData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage getImage() {
|
||||
if (cachedImage != null) {
|
||||
return cachedImage;
|
||||
}
|
||||
public InputStream getOriginalImageData() {
|
||||
if (swf.getJtt() != null) {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
byte[] jttdata = swf.getJtt().jpegData;
|
||||
@@ -122,7 +115,26 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener {
|
||||
int errorLength = hasErrorHeader(jpegData) ? 4 : 0;
|
||||
baos.write(jpegData.getArray(), jpegData.getPos() + errorLength, jpegData.getLength() - errorLength);
|
||||
|
||||
BufferedImage image = ImageHelper.read(baos.toByteArray());
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
// this should never happen, since IOException comes from OutputStream, but ByteArrayOutputStream should never throw it
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableImage getImage() {
|
||||
if (cachedImage != null) {
|
||||
return cachedImage;
|
||||
}
|
||||
|
||||
InputStream imageStream = getOriginalImageData();
|
||||
if (imageStream != null) {
|
||||
try {
|
||||
BufferedImage image = ImageHelper.read(imageStream);
|
||||
if (image == null) {
|
||||
Logger.getLogger(DefineBitsTag.class.getName()).log(Level.SEVERE, "Failed to load image");
|
||||
return null;
|
||||
@@ -138,6 +150,7 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener {
|
||||
Logger.getLogger(DefineBitsTag.class.getName()).log(Level.SEVERE, "Failed to get image", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
|
||||
import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundExportFormat;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -139,23 +140,23 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportFormat() {
|
||||
public SoundExportFormat getExportFormat() {
|
||||
if (soundFormat == SoundFormat.FORMAT_MP3) {
|
||||
return "mp3";
|
||||
return SoundExportFormat.MP3;
|
||||
}
|
||||
if (soundFormat == SoundFormat.FORMAT_ADPCM) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (soundFormat == SoundFormat.FORMAT_NELLYMOSER || soundFormat == SoundFormat.FORMAT_NELLYMOSER16KHZ || soundFormat == SoundFormat.FORMAT_NELLYMOSER8KHZ) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
return "flv";
|
||||
return SoundExportFormat.FLV;
|
||||
}
|
||||
|
||||
private void loadID3v2(InputStream in) {
|
||||
@@ -361,4 +362,15 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
|
||||
final int[] rateMap = {5512, 11025, 22050, 44100};
|
||||
return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTagInfo(TagInfo tagInfo) {
|
||||
super.getTagInfo(tagInfo);
|
||||
SoundFormat soundFormat = getSoundFormat();
|
||||
tagInfo.addInfo("general", "codecName", soundFormat.getFormatName());
|
||||
tagInfo.addInfo("general", "exportFormat", soundFormat.getNativeExportFormat());
|
||||
tagInfo.addInfo("general", "samplingRate", soundFormat.samplingRate);
|
||||
tagInfo.addInfo("general", "stereo", soundFormat.stereo);
|
||||
tagInfo.addInfo("general", "sampleCount", soundSampleCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Reserved;
|
||||
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;
|
||||
@@ -154,23 +155,23 @@ public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportFormat() {
|
||||
public SoundExportFormat getExportFormat() {
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
|
||||
return "mp3";
|
||||
return SoundExportFormat.MP3;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER16KHZ || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER8KHZ) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
return "flv";
|
||||
return SoundExportFormat.FLV;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,4 +253,15 @@ public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag {
|
||||
String exportName = swf.getExportName(getCharacterId());
|
||||
return getCharacterId() + (exportName != null ? "_" + exportName : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTagInfo(TagInfo tagInfo) {
|
||||
super.getTagInfo(tagInfo);
|
||||
SoundFormat soundFormat = getSoundFormat();
|
||||
tagInfo.addInfo("general", "codecName", soundFormat.getFormatName());
|
||||
tagInfo.addInfo("general", "exportFormat", soundFormat.getNativeExportFormat());
|
||||
tagInfo.addInfo("general", "samplingRate", soundFormat.samplingRate);
|
||||
tagInfo.addInfo("general", "stereo", soundFormat.stereo);
|
||||
tagInfo.addInfo("general", "sampleCount", streamSoundSampleCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Reserved;
|
||||
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;
|
||||
@@ -143,23 +144,23 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportFormat() {
|
||||
public SoundExportFormat getExportFormat() {
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
|
||||
return "mp3";
|
||||
return SoundExportFormat.MP3;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER16KHZ || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER8KHZ) {
|
||||
return "wav";
|
||||
return SoundExportFormat.WAV;
|
||||
}
|
||||
return "flv";
|
||||
return SoundExportFormat.FLV;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -251,4 +252,15 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
|
||||
String exportName = swf.getExportName(getCharacterId());
|
||||
return getCharacterId() + (exportName != null ? "_" + exportName : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTagInfo(TagInfo tagInfo) {
|
||||
super.getTagInfo(tagInfo);
|
||||
SoundFormat soundFormat = getSoundFormat();
|
||||
tagInfo.addInfo("general", "codecName", soundFormat.getFormatName());
|
||||
tagInfo.addInfo("general", "exportFormat", soundFormat.getNativeExportFormat());
|
||||
tagInfo.addInfo("general", "samplingRate", soundFormat.samplingRate);
|
||||
tagInfo.addInfo("general", "stereo", soundFormat.stereo);
|
||||
tagInfo.addInfo("general", "sampleCount", streamSoundSampleCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.TagInfo;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
@@ -41,6 +42,8 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Shape;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -61,7 +64,7 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag {
|
||||
super(swf, id, name, data);
|
||||
}
|
||||
|
||||
public abstract InputStream getImageData();
|
||||
public abstract InputStream getOriginalImageData();
|
||||
|
||||
public abstract SerializableImage getImage();
|
||||
|
||||
@@ -97,6 +100,17 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag {
|
||||
return ImageFormat.UNKNOWN;
|
||||
}
|
||||
|
||||
public InputStream getImageData() {
|
||||
InputStream is = getOriginalImageData();
|
||||
if (is != null) {
|
||||
return is;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(getImage().getBufferedImage(), getImageFormat(), baos);
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
public static boolean hasErrorHeader(byte[] data) {
|
||||
return hasErrorHeader(new ByteArrayRange(data));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundExportFormat;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import java.io.InputStream;
|
||||
@@ -28,7 +29,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface SoundTag extends TreeItem {
|
||||
|
||||
public String getExportFormat();
|
||||
public SoundExportFormat getExportFormat();
|
||||
|
||||
public boolean importSupported();
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.types.sound;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum SoundExportFormat {
|
||||
|
||||
WAV, MP3, FLV
|
||||
}
|
||||
@@ -57,31 +57,25 @@ public class SoundFormat {
|
||||
|
||||
public static final int FORMAT_SPEEX = 11;
|
||||
|
||||
public static final int EXPORT_WAV = 0;
|
||||
|
||||
public static final int EXPORT_MP3 = 1;
|
||||
|
||||
public static final int EXPORT_FLV = 2;
|
||||
|
||||
public SoundFormat() {
|
||||
|
||||
}
|
||||
|
||||
public int getNativeExportFormat() {
|
||||
public SoundExportFormat getNativeExportFormat() {
|
||||
switch (formatId) {
|
||||
case FORMAT_UNCOMPRESSED_NATIVE_ENDIAN:
|
||||
case FORMAT_UNCOMPRESSED_LITTLE_ENDIAN:
|
||||
case FORMAT_ADPCM:
|
||||
return EXPORT_WAV;
|
||||
return SoundExportFormat.WAV;
|
||||
case FORMAT_MP3:
|
||||
return EXPORT_MP3;
|
||||
return SoundExportFormat.MP3;
|
||||
case FORMAT_NELLYMOSER16KHZ:
|
||||
case FORMAT_NELLYMOSER8KHZ:
|
||||
case FORMAT_NELLYMOSER:
|
||||
case FORMAT_SPEEX:
|
||||
return EXPORT_FLV;
|
||||
return SoundExportFormat.FLV;
|
||||
default:
|
||||
return EXPORT_FLV;
|
||||
return SoundExportFormat.FLV;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +161,36 @@ public class SoundFormat {
|
||||
}
|
||||
}
|
||||
|
||||
public String getFormatName() {
|
||||
switch (formatId) {
|
||||
case FORMAT_UNCOMPRESSED_NATIVE_ENDIAN:
|
||||
return "Uncompressed native endian";
|
||||
|
||||
case FORMAT_ADPCM:
|
||||
return "ADPCM";
|
||||
|
||||
case FORMAT_MP3:
|
||||
return "MP3";
|
||||
|
||||
case FORMAT_UNCOMPRESSED_LITTLE_ENDIAN:
|
||||
return "Uncompressed little endian";
|
||||
|
||||
case FORMAT_NELLYMOSER16KHZ:
|
||||
return "NellyMoser 16kHz";
|
||||
|
||||
case FORMAT_NELLYMOSER8KHZ:
|
||||
return "NellyMoser 8kHz";
|
||||
|
||||
case FORMAT_NELLYMOSER:
|
||||
return "NellyMoser";
|
||||
|
||||
case FORMAT_SPEEX:
|
||||
return "Speex";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void writeLE(OutputStream os, long val, int size) throws IOException {
|
||||
for (int i = 0; i < size; i++) {
|
||||
os.write((int) (val & 0xff));
|
||||
|
||||
@@ -1661,7 +1661,7 @@ public class XFLConverter {
|
||||
}
|
||||
String soundEnvelopeStr = "";
|
||||
if (soundStreamHead != null && startSound == null) {
|
||||
String soundName = "sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat();
|
||||
String soundName = "sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat().toString().toLowerCase();
|
||||
ret.append(" soundName=\"").append(soundName).append("\"");
|
||||
ret.append(" soundSync=\"stream\"");
|
||||
soundEnvelopeStr += "<SoundEnvelope>";
|
||||
@@ -1669,7 +1669,7 @@ public class XFLConverter {
|
||||
soundEnvelopeStr += "</SoundEnvelope>";
|
||||
}
|
||||
if (startSound != null && sound != null) {
|
||||
String soundName = "sound" + sound.soundId + "." + sound.getExportFormat();
|
||||
String soundName = "sound" + sound.soundId + "." + sound.getExportFormat().toString().toLowerCase();
|
||||
ret.append(" soundName=\"").append(soundName).append("\"");
|
||||
if (startSound.soundInfo.hasInPoint) {
|
||||
ret.append(" inPoint44=\"").append(startSound.soundInfo.inPoint).append("\"");
|
||||
@@ -2141,7 +2141,7 @@ public class XFLConverter {
|
||||
if (ta instanceof DefineSoundTag) {
|
||||
DefineSoundTag s = (DefineSoundTag) ta;
|
||||
if (s.soundId == startSound.soundId) {
|
||||
if (!files.containsKey("sound" + s.soundId + "." + s.getExportFormat())) { //Sound was not exported
|
||||
if (!files.containsKey("sound" + s.soundId + "." + s.getExportFormat().toString().toLowerCase())) { //Sound was not exported
|
||||
startSound = null; // ignore
|
||||
}
|
||||
break;
|
||||
@@ -2152,7 +2152,7 @@ public class XFLConverter {
|
||||
}
|
||||
if (t instanceof SoundStreamHeadTypeTag) {
|
||||
soundStreamHead = (SoundStreamHeadTypeTag) t;
|
||||
if (!files.containsKey("sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat())) { //Sound was not exported
|
||||
if (!files.containsKey("sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat().toString().toLowerCase())) { //Sound was not exported
|
||||
soundStreamHead = null; // ignore
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user