diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java index 38ed9dad8..0e2d7abd9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java @@ -565,7 +565,7 @@ public class FrameExporter { File f = new File(foutdir + File.separator + fileNum + ".webp"); BufferedImage img = frameImages.next(); if (img != null) { - try(FileOutputStream fos = new FileOutputStream(f)) { + try (FileOutputStream fos = new FileOutputStream(f)) { fos.write(WebPCodec.encodeImage(img, 100f)); } } 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 104ea88d2..b22b7d5c7 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 @@ -111,11 +111,11 @@ public class ImageExporter { if (settings.mode == ImageExportMode.BMP) { fileFormat = ImageFormat.BMP; } - + if (settings.mode == ImageExportMode.WEBP) { fileFormat = ImageFormat.WEBP; } - + final File file = new File(outdir + File.separator + Helper.makeFileName(imageTag.getCharacterExportFileName() + "." + ImageHelper.getImageFormatString(fileFormat))); final ImageFormat ffileFormat = fileFormat; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java index be5f9c039..398df45d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -181,7 +181,7 @@ public class MorphShapeExporter { if (settings.mode == MorphShapeExportMode.PNG_START_END) { ImageHelper.write(img.getBufferedImage(), ImageFormat.PNG, fileStart); } else if (settings.mode == MorphShapeExportMode.WEBP_START_END) { - try(FileOutputStream fos = new FileOutputStream(fileStart)) { + try (FileOutputStream fos = new FileOutputStream(fileStart)) { fos.write(WebPCodec.encodeImage(img.getBufferedImage(), 100f)); } } else { @@ -208,7 +208,7 @@ public class MorphShapeExporter { if (settings.mode == MorphShapeExportMode.PNG_START_END) { ImageHelper.write(img.getBufferedImage(), ImageFormat.PNG, fileEnd); } else if (settings.mode == MorphShapeExportMode.WEBP_START_END) { - try(FileOutputStream fos = new FileOutputStream(fileEnd)) { + try (FileOutputStream fos = new FileOutputStream(fileEnd)) { fos.write(WebPCodec.encodeImage(img.getBufferedImage(), 100f)); } } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java index b9e1fc276..9349343e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -140,7 +140,7 @@ public class ShapeExporter { if (settings.mode == ShapeExportMode.PNG) { ImageHelper.write(img.getBufferedImage(), ImageFormat.PNG, file); } else if (settings.mode == ShapeExportMode.WEBP) { - try(FileOutputStream fos = new FileOutputStream(file)) { + try (FileOutputStream fos = new FileOutputStream(file)) { fos.write(WebPCodec.encodeImage(img.getBufferedImage(), 100f)); } } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ImageImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ImageImporter.java index 0a7d4e55c..a5cebc545 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ImageImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ImageImporter.java @@ -54,6 +54,7 @@ public class ImageImporter extends TagImporter { /** * Imports image. + * * @param it Image tag * @param newData New data * @return Imported tag @@ -65,6 +66,7 @@ public class ImageImporter extends TagImporter { /** * Imports image. + * * @param it Image tag * @param newData New data * @param tagType 0 = can change for defineBits, -1 = detect based on data @@ -78,12 +80,12 @@ public class ImageImporter extends TagImporter { ImageHelper.write(b, ImageFormat.PNG, baos); newData = baos.toByteArray(); } - if (newData.length >= 4 + if (newData.length >= 4 && newData[0] == 'R' && newData[1] == 'I' && newData[2] == 'F' - && newData[3] == 'F') - { + && newData[3] == 'F' + ) { if (!ImageFormat.WEBP.available()) { throw new RuntimeException("WEBP format is not supported on your platform"); } @@ -162,6 +164,7 @@ public class ImageImporter extends TagImporter { /** * Imports image alpha. + * * @param it Image tag * @param newData New data * @return Imported tag @@ -197,6 +200,7 @@ public class ImageImporter extends TagImporter { /** * Converts image. + * * @param it Image tag * @param tagType 0 = can change for defineBits, -1 = detect based on data * @throws IOException On I/O error @@ -207,6 +211,7 @@ public class ImageImporter extends TagImporter { /** * Gets image tag type. + * * @param format Format * @return Image tag type */ @@ -235,6 +240,7 @@ public class ImageImporter extends TagImporter { /** * Bulk import images. + * * @param imagesDir Images directory * @param swf SWF * @param printOut Print out diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java index 5d5d0075e..be8be2b2b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java @@ -63,6 +63,7 @@ public class ShapeImporter { /** * Imports an image to a shape tag. + * * @param st Shape tag * @param newData New image data * @return Imported tag @@ -74,6 +75,7 @@ public class ShapeImporter { /** * Imports an image to a morph shape tag. + * * @param mst Morph shape tag * @param newData New image data * @return Imported tag @@ -85,6 +87,7 @@ public class ShapeImporter { /** * Imports an image to morph shape tag. + * * @param mst Morph shape tag * @param newData New image data * @param tagType Tag type @@ -98,6 +101,7 @@ public class ShapeImporter { /** * Imports an image to shape tag. + * * @param st Shape tag * @param newData New image data * @param tagType Tag type @@ -164,13 +168,13 @@ public class ShapeImporter { ImageHelper.write(b, ImageFormat.PNG, baos); newData = baos.toByteArray(); } - - if (newData.length >= 4 + + if (newData.length >= 4 && newData[0] == 'R' && newData[1] == 'I' && newData[2] == 'F' - && newData[3] == 'F') - { + && newData[3] == 'F' + ) { if (!ImageFormat.WEBP.available()) { throw new RuntimeException("WEBP format is not supported on your platform"); } @@ -225,6 +229,7 @@ public class ShapeImporter { /** * Gets the shape tag type. + * * @param format Format * @return Shape tag type */ @@ -250,6 +255,7 @@ public class ShapeImporter { /** * Bulk import shapes. + * * @param shapesDir Shapes directory * @param swf SWF * @param noFill No fill flag diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index ea1904044..7ed1ece03 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -161,7 +161,7 @@ public class ExportDialog extends AppDialog { public E getValue(Class option) { for (int i = 0; i < optionClasses.length; i++) { - if (option == optionClasses[i]) { + if (option == optionClasses[i]) { return (E) ((ComboValue) combos[i].getSelectedItem()).value; } } @@ -242,7 +242,7 @@ public class ExportDialog extends AppDialog { } return false; } - + private String translateTitle(String title) { return translate("titleFormat").replace("%title%", translate(title)); } @@ -258,7 +258,7 @@ public class ExportDialog extends AppDialog { comboPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(2, 2, 2, 2); - + int labWidth = 0; boolean[] exportableExistsArray = new boolean[optionNames.length]; for (int i = 0; i < optionNames.length; i++) { @@ -315,8 +315,8 @@ public class ExportDialog extends AppDialog { }); gbc.gridy = 0; gbc.gridx = 3; - comboPanel.add(selectAllCheckBox, gbc); - + comboPanel.add(selectAllCheckBox, gbc); + List visibleOptionClasses = new ArrayList<>(); boolean zoomable = false; @@ -328,31 +328,28 @@ public class ExportDialog extends AppDialog { for (int j = 0; j < vals.length; j++) { try { Method availableMethod = c.getMethod("available"); - if (!(Boolean)availableMethod.invoke(vals[j])) - { + if (!(Boolean) availableMethod.invoke(vals[j])) { continue; } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { //ignore } - //ignore - //ignore - + String key = optionNames[i] + "." + vals[j].toString().toLowerCase(Locale.ENGLISH); if (exportFormats.contains(key)) { itemIndex = j; } - + namesList.add(new ComboValue(vals[j], translate(key))); } ComboValue[] names = namesList.toArray(new ComboValue[0]); - + combos[i] = new JComboBox<>(names); if (itemIndex > -1) { combos[i].setSelectedIndex(itemIndex); } - + checkBoxes[i] = new JCheckBox(); checkBoxes[i].setSelected(true); @@ -376,13 +373,13 @@ public class ExportDialog extends AppDialog { gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = 2; comboPanel.add(combos[i], gbc); - gbc.gridx += 2; + gbc.gridx += 2; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; comboPanel.add(checkBoxes[i], gbc); lab.setLabelFor(combos[i]); - } + } embedCheckBox = new JCheckBox(translate("embed")); embedCheckBox.setVisible(false); @@ -398,16 +395,16 @@ public class ExportDialog extends AppDialog { } } } - - gbc.gridx = 0; - gbc.gridwidth = 4; + + gbc.gridx = 0; + gbc.gridwidth = 4; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.LINE_START; - + if (hasAs3 && visibleOptionClasses.contains(ScriptExportMode.class)) { gbc.gridy++; embedCheckBox.setVisible(true); - comboPanel.add(embedCheckBox, gbc); + comboPanel.add(embedCheckBox, gbc); if (Configuration.lastExportEnableEmbed.get()) { embedCheckBox.setSelected(true); } @@ -439,18 +436,18 @@ public class ExportDialog extends AppDialog { if (zoomable) { JLabel zlab = new JLabel(translateTitle("zoom")); - JLabel pctLabel = new JLabel(translate("zoom.percent")); + JLabel pctLabel = new JLabel(translate("zoom.percent")); zlab.setLabelFor(zoomTextField); gbc.gridy++; gbc.gridx = 0; - gbc.gridwidth = 1; + gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.LINE_END; comboPanel.add(zlab, gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.LINE_START; comboPanel.add(zoomTextField, gbc); gbc.gridx++; - gbc.anchor = GridBagConstraints.LINE_START; + gbc.anchor = GridBagConstraints.LINE_START; comboPanel.add(pctLabel, gbc); } @@ -510,8 +507,9 @@ public class ExportDialog extends AppDialog { setVisible(true); return result; } - + private class ComboValue { + public Object value; public String text; @@ -523,6 +521,6 @@ public class ExportDialog extends AppDialog { @Override public String toString() { return text; - } + } } } diff --git a/src/com/jpexs/decompiler/flash/gui/FileChooserImagePreview.java b/src/com/jpexs/decompiler/flash/gui/FileChooserImagePreview.java index 06846d589..03fbb45a0 100644 --- a/src/com/jpexs/decompiler/flash/gui/FileChooserImagePreview.java +++ b/src/com/jpexs/decompiler/flash/gui/FileChooserImagePreview.java @@ -104,7 +104,7 @@ public class FileChooserImagePreview extends JComponent } } } else { - try(FileInputStream fis = new FileInputStream(file)) { + try (FileInputStream fis = new FileInputStream(file)) { img = ImageHelper.read(fis); } catch (IOException ex) { //ignore