From c4903427518934a1a51091cc91949aff9d269269 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 31 May 2015 14:05:22 +0200 Subject: [PATCH 1/5] #858: allow to set compression in header edit panel --- .../src/com/jpexs/decompiler/flash/SWF.java | 2 +- .../decompiler/flash/gui/HeaderInfoPanel.java | 91 ++++++++++++++++++- .../flash/gui/locales/MainFrame.properties | 4 + .../flash/gui/locales/MainFrame_hu.properties | 6 ++ 4 files changed, 98 insertions(+), 5 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 58ba8a284..47d847c1e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -642,7 +642,7 @@ public final class SWF implements SWFContainerItem, Timelined { } private String getHeaderBytes(SWFCompression compression, boolean gfx) { - if (compression == SWFCompression.LZMA_ABC) { + if (compression == SWFCompression.LZMA_ABC || true) { return "ABC"; } diff --git a/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java index ac487f885..31604e00c 100644 --- a/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java @@ -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> 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 item = (ComboBoxItem) 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 diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 4cc2c2faa..a01ce3e73 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -607,3 +607,7 @@ 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. diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 58f7d5e59..843a4e5d3 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -604,3 +604,9 @@ 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. From e58fba26c50e986bdbcec1aa6d581b84dc768029 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 31 May 2015 15:11:41 +0200 Subject: [PATCH 2/5] small fix --- libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 47d847c1e..58ba8a284 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -642,7 +642,7 @@ public final class SWF implements SWFContainerItem, Timelined { } private String getHeaderBytes(SWFCompression compression, boolean gfx) { - if (compression == SWFCompression.LZMA_ABC || true) { + if (compression == SWFCompression.LZMA_ABC) { return "ABC"; } From fe9fbfa63f3f8a1b595d269a363ecb4f8f88a28b Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 31 May 2015 15:42:19 +0200 Subject: [PATCH 3/5] Swedish translation --- .../decompiler/flash/gui/locales/MainFrame_sv.properties | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_sv.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_sv.properties index 69b2ba54a..66d99f825 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_sv.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_sv.properties @@ -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 \ No newline at end of file +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. From 0aab5135624c28872835b71889578b3fb6623a8a Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 31 May 2015 16:55:13 +0200 Subject: [PATCH 4/5] #904 I can't export images fixed --- .../src/com/jpexs/decompiler/flash/SWF.java | 11 +------ .../flash/exporters/ImageExporter.java | 7 +++- .../morphshape/SVGMorphShapeExporter.java | 13 +------- .../exporters/shape/SVGShapeExporter.java | 13 +------- .../flash/tags/DefineBitsJPEG2Tag.java | 4 +-- .../flash/tags/DefineBitsJPEG3Tag.java | 9 ++--- .../flash/tags/DefineBitsJPEG4Tag.java | 8 ++--- .../flash/tags/DefineBitsLossless2Tag.java | 2 +- .../flash/tags/DefineBitsLosslessTag.java | 2 +- .../decompiler/flash/tags/DefineBitsTag.java | 33 +++++++++++++------ .../decompiler/flash/tags/base/ImageTag.java | 16 ++++++++- 11 files changed, 55 insertions(+), 63 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 58ba8a284..4423c8a08 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -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")); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java index 96453d508..be1a16d0d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java @@ -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 { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java index d8bf43904..32b53d4fb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java @@ -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"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java index 45f064077..6bedf6253 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java @@ -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"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java index b7ef635b5..db658f94b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java @@ -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; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java index 87391402a..27cf9a44e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java @@ -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 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java index d60790d11..867571011 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java @@ -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 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java index 8506ac6b1..d41a50e1b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java @@ -228,7 +228,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { } @Override - public InputStream getImageData() { + public InputStream getOriginalImageData() { return null; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java index 367d7d6f3..4110ce3ec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java @@ -190,7 +190,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { } @Override - public InputStream getImageData() { + public InputStream getOriginalImageData() { return null; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java index fcfcd0980..fadf45e3b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java @@ -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; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java index bdb66f278..7be657c57 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java @@ -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)); } From 4acdd7e029f19da5d4cfe5f69fad736ea72044dc Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 31 May 2015 20:41:35 +0200 Subject: [PATCH 5/5] #905 Show codec details for sound items --- .../flash/exporters/SoundExporter.java | 11 +++-- .../decompiler/flash/tags/DefineSoundTag.java | 26 ++++++++--- .../flash/tags/SoundStreamHead2Tag.java | 26 ++++++++--- .../flash/tags/SoundStreamHeadTag.java | 26 ++++++++--- .../decompiler/flash/tags/base/SoundTag.java | 3 +- .../flash/types/sound/SoundExportFormat.java | 26 +++++++++++ .../flash/types/sound/SoundFormat.java | 46 ++++++++++++++----- .../decompiler/flash/xfl/XFLConverter.java | 8 ++-- .../decompiler/flash/gui/TagInfoPanel.java | 8 +++- .../flash/gui/locales/MainFrame.properties | 6 +++ .../flash/gui/locales/MainFrame_hu.properties | 6 +++ 11 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundExportFormat.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java index a9c81cc03..611a6ba39 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java @@ -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 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); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java index c10608e47..2a815c69d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java @@ -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); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java index 0a608375b..ba8f81f4c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java @@ -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); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index 8575794bb..6dc707262 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -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); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java index d8f22152f..c839acdfa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java @@ -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(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundExportFormat.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundExportFormat.java new file mode 100644 index 000000000..dbad7fe21 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundExportFormat.java @@ -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 +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java index 6f1d5357e..7d638e3dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java @@ -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)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 86a0eaa5f..262d601ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -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 += ""; @@ -1669,7 +1669,7 @@ public class XFLConverter { soundEnvelopeStr += ""; } 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 } } diff --git a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java index 88d836536..23e384537 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java @@ -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; } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index a01ce3e73..5774d0dbf 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -611,3 +611,9 @@ 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 diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 843a4e5d3..9df945f87 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -610,3 +610,9 @@ 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