Merge origin/master

This commit is contained in:
Jindra Petřík
2015-06-01 07:05:28 +02:00
24 changed files with 308 additions and 111 deletions

View File

@@ -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"));
}

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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");

View File

@@ -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");

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -228,7 +228,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
}
@Override
public InputStream getImageData() {
public InputStream getOriginalImageData() {
return null;
}

View File

@@ -190,7 +190,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
}
@Override
public InputStream getImageData() {
public InputStream getOriginalImageData() {
return null;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}

View File

@@ -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();

View File

@@ -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
}

View File

@@ -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));

View File

@@ -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
}
}

View File

@@ -17,19 +17,23 @@
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFCompression;
import com.jpexs.decompiler.flash.gui.helpers.TableLayoutHelper;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.event.ChangeEvent;
import layout.TableLayout;
/**
@@ -56,6 +60,10 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
private final JLabel displayRectPixelsLabel = new JLabel();
private final JPanel compressionEditorPanel = new JPanel();
private final JComboBox<ComboBoxItem<SWFCompression>> compressionComboBox = new JComboBox<>();
private final JPanel versionEditorPanel = new JPanel();
private final JSpinner versionEditor = new JSpinner();
@@ -86,6 +94,10 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
private final JSpinner yMaxEditor = new JSpinner();
private final JPanel warningPanel = new JPanel();
private final JLabel warningLabel = new JLabel();
private SWF swf;
public HeaderInfoPanel() {
@@ -96,17 +108,34 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
{TableLayout.PREFERRED, TableLayout.FILL},
{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED}
}));
FlowLayout layout = new FlowLayout(SwingConstants.WEST);
layout.setHgap(0);
layout.setVgap(0);
compressionEditorPanel.setLayout(layout);
compressionComboBox.addItem(new ComboBoxItem<>(AppStrings.translate("header.uncompressed"), SWFCompression.NONE));
compressionComboBox.addItem(new ComboBoxItem<>("Zlib", SWFCompression.ZLIB));
compressionComboBox.addItem(new ComboBoxItem<>("LZMA", SWFCompression.LZMA));
compressionComboBox.addActionListener((ActionEvent e) -> {
validateHeader();
});
compressionEditorPanel.add(compressionComboBox);
versionEditorPanel.setLayout(layout);
versionEditor.setPreferredSize(new Dimension(80, versionEditor.getPreferredSize().height));
versionEditor.addChangeListener((ChangeEvent e) -> {
validateHeader();
});
versionEditorPanel.add(versionEditor);
gfxCheckBox.addActionListener((ActionEvent e) -> {
validateHeader();
});
frameRateEditorPanel.setLayout(layout);
frameRateEditor.setPreferredSize(new Dimension(80, frameRateEditor.getPreferredSize().height));
frameRateEditorPanel.add(frameRateEditor);
@@ -126,10 +155,16 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
displayRectEditorPanel.add(yMaxEditor);
displayRectEditorPanel.add(new JLabel(" twips"));
warningLabel.setIcon(View.getIcon("warning16"));
warningPanel.setLayout(layout);
warningPanel.setBackground(new Color(255, 213, 29));
warningPanel.add(warningLabel);
propertiesPanel.add(new JLabel(AppStrings.translate("header.signature")), "0,0");
propertiesPanel.add(signatureLabel, "1,0");
propertiesPanel.add(new JLabel(AppStrings.translate("header.compression")), "0,1");
propertiesPanel.add(compressionLabel, "1,1");
propertiesPanel.add(compressionEditorPanel, "1,1");
propertiesPanel.add(new JLabel(AppStrings.translate("header.version")), "0,2");
propertiesPanel.add(versionLabel, "1,2");
propertiesPanel.add(versionEditorPanel, "1,2");
@@ -148,6 +183,7 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
propertiesPanel.add(displayRectEditorPanel, "1,7");
propertiesPanel.add(new JLabel(""), "0,8");
propertiesPanel.add(displayRectPixelsLabel, "1,8");
propertiesPanel.add(warningPanel, "0,9,1,9");
add(propertiesPanel, BorderLayout.CENTER);
@@ -171,12 +207,23 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
setEditMode(false);
}
private int getVersionNumber() {
return (int) versionEditor.getModel().getValue();
}
private SWFCompression getCompression() {
@SuppressWarnings("unchecked")
ComboBoxItem<SWFCompression> item = (ComboBoxItem<SWFCompression>) compressionComboBox.getSelectedItem();
return item.getValue();
}
private void editButtonActionPerformed(ActionEvent evt) {
setEditMode(true);
}
private void saveButtonActionPerformed(ActionEvent evt) {
swf.version = (int) versionEditor.getModel().getValue();
swf.compression = getCompression();
swf.version = getVersionNumber();
swf.gfx = gfxCheckBox.isSelected();
swf.frameRate = (int) frameRateEditor.getModel().getValue();
swf.displayRect.Xmin = (int) xMinEditor.getModel().getValue();
@@ -199,12 +246,15 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
switch (swf.compression) {
case LZMA:
compressionLabel.setText(AppStrings.translate("header.compression.lzma"));
compressionComboBox.setSelectedIndex(2);
break;
case ZLIB:
compressionLabel.setText(AppStrings.translate("header.compression.zlib"));
compressionComboBox.setSelectedIndex(1);
break;
case NONE:
compressionLabel.setText(AppStrings.translate("header.compression.none"));
compressionComboBox.setSelectedIndex(0);
break;
}
@@ -253,22 +303,55 @@ public class HeaderInfoPanel extends JPanel implements TagEditorPanel {
}
private void setEditMode(boolean edit) {
compressionLabel.setVisible(!edit);
compressionEditorPanel.setVisible(edit);
versionLabel.setVisible(!edit);
versionEditor.setVisible(edit);
versionEditorPanel.setVisible(edit);
gfxLabel.setVisible(!edit);
gfxCheckBox.setVisible(edit);
frameRateLabel.setVisible(!edit);
frameRateEditor.setVisible(edit);
frameRateEditorPanel.setVisible(edit);
displayRectTwipsLabel.setVisible(!edit);
displayRectPixelsLabel.setVisible(!edit);
displayRectEditorPanel.setVisible(edit);
warningPanel.setVisible(false);
editButton.setVisible(!edit);
saveButton.setVisible(edit);
cancelButton.setVisible(edit);
}
private boolean validateHeader() {
int version = getVersionNumber();
boolean gfx = gfxCheckBox.isSelected();
SWFCompression compression = getCompression();
String resultStr = "";
boolean result = true;
if (gfx && !(compression == SWFCompression.NONE || compression == SWFCompression.ZLIB)) {
resultStr += AppStrings.translate("header.warning.unsupportedGfxCompression") + " ";
result = false;
}
if (compression == SWFCompression.ZLIB && version < 6) {
resultStr += AppStrings.translate("header.warning.minimumZlibVersion") + " ";
result = false;
}
if (compression == SWFCompression.LZMA && version < 13) {
resultStr += AppStrings.translate("header.warning.minimumLzmaVersion") + " ";
result = false;
}
warningPanel.setVisible(!result);
if (!result) {
warningLabel.setText(resultStr);
}
return result;
}
@Override
public boolean tryAutoSave() {
// todo: implement

View File

@@ -124,7 +124,13 @@ public class TagInfoPanel extends JPanel {
return name;
case 1:
return "" + item.getValue();
Object value = item.getValue();
if (value instanceof Boolean) {
boolean boolValue = (boolean) value;
return boolValue ? AppStrings.translate("yes") : AppStrings.translate("no");
}
return "" + value;
}
}

View File

@@ -607,3 +607,13 @@ taginfo.header = Basic tag info
tagInfo.dependentCharacters = Dependent Characters
#after version 5.3.0
header.uncompressed = Uncompressed
header.warning.unsupportedGfxCompression = GFX supports only uncompressed or Zlib compressed content.
header.warning.minimumZlibVersion = Zlib compression needs SWF version 6 or greater.
header.warning.minimumLzmaVersion = LZMA compression needs SWF version 13 or greater.
tagInfo.codecName = Codec Name
tagInfo.exportFormat = Export Format
tagInfo.samplingRate = Sampling Rate
tagInfo.stereo = Stereo
tagInfo.sampleCount = Sample Count

View File

@@ -604,3 +604,15 @@ button.viewhexpcode = Hexa mutat\u00e1sa utas\u00edt\u00e1sokkal
taginfo.header = Alap tag info
tagInfo.dependentCharacters = F\u00fcgg\u0151 karakterek
#after version 5.3.0
header.uncompressed = T\u00f6m\u00f6r\u00edtetlen
header.warning.unsupportedGfxCompression = GFX csak t\u00f6m\u00f6r\u00edtetlen \u00e9s Zlib t\u00f6m\u00f6r\u00edtett tartalmakat t\u00e1mogat.
header.warning.minimumZlibVersion = Zlib t\u00f6m\u00f6r\u00edt\u00e9shez 6-os vagy nagyobb SWF verzi\u00f3ra van sz\u00fcks\u00e9g.
header.warning.minimumLzmaVersion = LZMA t\u00f6m\u00f6r\u00edt\u00e9shez 13-as vagy nagyobb SWF verzi\u00f3ra van sz\u00fcks\u00e9g.
tagInfo.codecName = Codec neve
tagInfo.exportFormat = Export\u00e1l\u00e1si form\u00e1tum
tagInfo.samplingRate = Mintav\u00e9telez\u00e9si frekvencia
tagInfo.stereo = Sztere\u00f3
tagInfo.sampleCount = Mint\u00e1k sz\u00e1ma

View File

@@ -604,4 +604,10 @@ tagInfo.neededCharacters = Beh\u00f6vande Tecken
button.viewhexpcode = Granska Hex med instruktioner
taginfo.header = Grundl\u00e4ggande tag information
tagInfo.dependentCharacters = Beroende Tecken
tagInfo.dependentCharacters = Beroende Tecken
#after version 5.3.0
header.uncompressed = Okomprimerad
header.warning.unsupportedGfxCompression = GFX st\u00f6der endast okomprimerat eller Zlib komprimerad inneh\u00e5ll.
header.warning.minimumZlibVersion = Zlib kompression beh\u00f6ver SWF version 6 eller st\u00f6rre.
header.warning.minimumLzmaVersion = LZMA kompression beh\u00f6ver SWF version 13 eller st\u00f6rre.