From cdae56d128cb0c58cdbc43e2f3a5e63468003e08 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 7 Dec 2014 12:41:55 +0100 Subject: [PATCH] small refactorings --- .../src/com/jpexs/decompiler/flash/SWF.java | 12 ++--- .../jpexs/decompiler/flash/action/Action.java | 2 +- .../flash/configuration/Configuration.java | 4 -- .../flash/exporters/ImageExporter.java | 5 +- .../flash/exporters/ShapeExporter.java | 4 +- .../exporters/commonshape/SVGExporter.java | 6 +-- .../morphshape/SVGMorphShapeExporter.java | 11 ++--- .../exporters/shape/SVGShapeExporter.java | 11 ++--- .../decompiler/flash/helpers/FontHelper.java | 20 ++++++-- .../decompiler/flash/helpers/ImageHelper.java | 49 +++++++++++++++++++ .../flash/importers/ImageImporter.java | 6 +-- .../flash/importers/ShapeImporter.java | 6 +-- .../flash/tags/DefineBitsJPEG2Tag.java | 4 +- .../flash/tags/DefineBitsJPEG3Tag.java | 6 +-- .../flash/tags/DefineBitsJPEG4Tag.java | 4 +- .../flash/tags/DefineBitsLossless2Tag.java | 4 +- .../flash/tags/DefineBitsLosslessTag.java | 4 +- .../decompiler/flash/tags/DefineBitsTag.java | 4 +- .../decompiler/flash/tags/DefineFont2Tag.java | 6 +-- .../decompiler/flash/tags/DefineFont3Tag.java | 6 +-- .../decompiler/flash/tags/DefineText2Tag.java | 4 +- .../decompiler/flash/tags/DefineTextTag.java | 2 +- .../decompiler/flash/tags/base/FontTag.java | 4 +- .../tags/base/MissingCharacterHandler.java | 2 +- .../flash/tags/gfx/DefineCompactedFont.java | 4 +- .../flash/types/shaperecords/SHAPERECORD.java | 4 +- .../decompiler/flash/xfl/XFLConverter.java | 8 +-- .../src/com/jpexs/helpers/Helper.java | 7 ++- .../com/jpexs/helpers/SerializableImage.java | 6 +-- .../cache/chrome/BlockFileHeader.java | 19 +++---- .../flash/gui/FolderPreviewPanel.java | 2 +- .../flash/gui/LoadFromCacheFrame.java | 6 +-- .../jpexs/decompiler/flash/gui/MainPanel.java | 10 ++-- .../flash/gui/abc/UndoFixedEditorPane.java | 2 +- .../flash/gui/debugger/Debugger.java | 6 +-- .../flash/gui/tagtree/TagTreeModel.java | 2 +- 36 files changed, 154 insertions(+), 108 deletions(-) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/ImageHelper.java 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 d07098a2a..2aecae50f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -85,6 +85,7 @@ import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.helpers.BMPFile; 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; @@ -197,10 +198,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; -import javax.imageio.ImageIO; import javax.imageio.stream.FileImageOutputStream; import javax.imageio.stream.ImageOutputStream; -import javax.xml.bind.DatatypeConverter; import net.kroo.elliot.GifSequenceWriter; import org.monte.media.VideoFormatKeys; import org.monte.media.avi.AVIWriter; @@ -1280,13 +1279,10 @@ public final class SWF implements SWFContainerItem, Timelined { imageData = Helper.readStream(image.getImageData()); } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - ImageIO.write(image.getImage().getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); - } catch (IOException ex) { - } + ImageHelper.write(image.getImage().getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); imageData = baos.toByteArray(); } - String base64ImgData = DatatypeConverter.printBase64Binary(imageData); + 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")); } fos.write(Utf8Helper.getBytes("function " + getTypePrefix(ch) + c + "(ctx,ctrans,frame,ratio,time){\r\n")); @@ -1534,7 +1530,7 @@ public final class SWF implements SWFContainerItem, Timelined { @Override public void run() throws IOException { File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png"); - ImageIO.write(frameImages.next(), "PNG", f); + ImageHelper.write(frameImages.next(), "PNG", new FileOutputStream(f)); ret.add(f); } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index bf42a993b..da3050289 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -97,7 +97,7 @@ import java.util.logging.Logger; public class Action implements GraphSourceItem { private static final int INFORM_LISTENER_RESOLUTION = 100; - + private boolean ignored = false; /** * Action type identifier diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 415097b87..03597dd06 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -19,10 +19,7 @@ package com.jpexs.decompiler.flash.configuration; import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.helpers.Helper; -import com.jpexs.helpers.utf8.Utf8InputStreamReader; -import com.jpexs.helpers.utf8.Utf8OutputStreamWriter; import java.io.BufferedOutputStream; -import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -30,7 +27,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.PrintWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; 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 84a0059c5..5ed94b1ca 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 @@ -22,15 +22,16 @@ import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings; import com.jpexs.decompiler.flash.helpers.BMPFile; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.helpers.Helper; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import javax.imageio.ImageIO; /** * @@ -77,7 +78,7 @@ public class ImageExporter { if (ffileFormat.equals("bmp")) { BMPFile.saveBitmap(imageTag.getImage().getBufferedImage(), file); } else { - ImageIO.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); + ImageHelper.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), new FileOutputStream(file)); } } }, handler).run(); 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 83456edf4..87966abbc 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 @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings; import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.helpers.BMPFile; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -45,7 +46,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.imageio.ImageIO; /** * @@ -114,7 +114,7 @@ public class ShapeExporter { m.scale(settings.zoom); st.toImage(0, 0, 0, null, 0, img, m, new CXFORMWITHALPHA()); if (settings.mode == ShapeExportMode.PNG) { - ImageIO.write(img.getBufferedImage(), "PNG", new FileOutputStream(file)); + ImageHelper.write(img.getBufferedImage(), "PNG", new FileOutputStream(file)); } else { BMPFile.saveBitmap(img.getBufferedImage(), file); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java index d05dc17d9..cd369eb53 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters.commonshape; import com.jpexs.decompiler.flash.SWF; @@ -32,7 +33,6 @@ import java.util.Map; import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; -import javax.xml.bind.DatatypeConverter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -213,7 +213,7 @@ public class SVGExporter { public void addStyle(String fontFace, byte[] data, FontExportMode mode) { if (!fontFaces.contains(fontFace)) { fontFaces.add(fontFace); - String base64Data = DatatypeConverter.printBase64Binary(data); + String base64Data = Helper.byteArrayToBase64String(data); String value = getStyle().getTextContent(); value += Helper.newLine; value += " @font-face {" + Helper.newLine; 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 2b4831590..9172e56a1 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,6 +19,7 @@ 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.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.ColorTransform; @@ -33,11 +34,8 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.util.Locale; -import javax.imageio.ImageIO; -import javax.xml.bind.DatatypeConverter; import org.w3c.dom.Element; /** @@ -130,13 +128,10 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter { imageData = Helper.readStream(image.getImageData()); } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - ImageIO.write(img.getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); - } catch (IOException ex) { - } + ImageHelper.write(img.getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); imageData = baos.toByteArray(); } - String base64ImgData = DatatypeConverter.printBase64Binary(imageData); + String base64ImgData = Helper.byteArrayToBase64String(imageData); path.setAttribute("style", "fill:url(#" + patternId + ")"); Element pattern = exporter.createElement("pattern"); pattern.setAttribute("id", patternId); 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 976e8f82c..8ef1cf532 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,6 +19,7 @@ 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.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.ColorTransform; @@ -33,11 +34,8 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.util.Locale; -import javax.imageio.ImageIO; -import javax.xml.bind.DatatypeConverter; import org.w3c.dom.Element; /** @@ -128,13 +126,10 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter { imageData = Helper.readStream(image.getImageData()); } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - ImageIO.write(img.getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); - } catch (IOException ex) { - } + ImageHelper.write(img.getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); imageData = baos.toByteArray(); } - String base64ImgData = DatatypeConverter.printBase64Binary(imageData); + String base64ImgData = Helper.byteArrayToBase64String(imageData); path.setAttribute("style", "fill:url(#" + patternId + ")"); Element pattern = exporter.createElement("pattern"); pattern.setAttribute("id", patternId); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java index 899d7df9a..68e0e1cd3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java @@ -118,14 +118,14 @@ public class FontHelper { withKerningAttrs.put(TextAttribute.FONT, font); withKerningAttrs.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); Font withKerningFont = Font.getFont(withKerningAttrs); - GlyphVector withKerningVector = withKerningFont.layoutGlyphVector((new JPanel()).getFontMetrics(withKerningFont).getFontRenderContext(), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); + GlyphVector withKerningVector = withKerningFont.layoutGlyphVector(getFontRenderContext(withKerningFont), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int withKerningX = withKerningVector.getGlyphLogicalBounds(1).getBounds().x; Map noKerningAttrs = new HashMap<>(); noKerningAttrs.put(TextAttribute.FONT, font); noKerningAttrs.put(TextAttribute.KERNING, 0); Font noKerningFont = Font.getFont(noKerningAttrs); - GlyphVector noKerningVector = noKerningFont.layoutGlyphVector((new JPanel()).getFontMetrics(noKerningFont).getFontRenderContext(), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); + GlyphVector noKerningVector = noKerningFont.layoutGlyphVector(getFontRenderContext(noKerningFont), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int noKerningX = noKerningVector.getGlyphLogicalBounds(1).getBounds().x; return withKerningX - noKerningX; } @@ -162,6 +162,18 @@ public class FontHelper { return ret; } + public static float getFontAdvance(Font font, char ch) { + return createGlyphVector(font, ch).getGlyphMetrics(0).getAdvanceX(); + } + + public static GlyphVector createGlyphVector(Font font, char ch) { + return font.createGlyphVector(getFontRenderContext(font), new char[]{ch}); + } + + private static FontRenderContext getFontRenderContext(Font font) { + return (new JPanel()).getFontMetrics(font).getFontRenderContext(); + } + private static List getFontKerningPairsOneChar(List availableChars, Font font, char firstChar) { List ret = new ArrayList<>(); @@ -177,7 +189,7 @@ public class FontHelper { withKerningAttrs.put(TextAttribute.FONT, font); withKerningAttrs.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); Font withKerningFont = Font.getFont(withKerningAttrs); - GlyphVector withKerningVector = withKerningFont.layoutGlyphVector((new JPanel()).getFontMetrics(withKerningFont).getFontRenderContext(), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); + GlyphVector withKerningVector = withKerningFont.layoutGlyphVector(getFontRenderContext(withKerningFont), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int withKerningX[] = new int[availableChars.size()]; for (int i = 0; i < availableChars.size(); i++) { withKerningX[i] = withKerningVector.getGlyphLogicalBounds(i * 2 + 1).getBounds().x; @@ -187,7 +199,7 @@ public class FontHelper { noKerningAttrs.put(TextAttribute.FONT, font); noKerningAttrs.put(TextAttribute.KERNING, 0); Font noKerningFont = Font.getFont(noKerningAttrs); - GlyphVector noKerningVector = noKerningFont.layoutGlyphVector((new JPanel()).getFontMetrics(noKerningFont).getFontRenderContext(), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); + GlyphVector noKerningVector = noKerningFont.layoutGlyphVector(getFontRenderContext(noKerningFont), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); for (int i = 0; i < availableChars.size(); i++) { int noKerningX = noKerningVector.getGlyphLogicalBounds(i * 2 + 1).getBounds().x; int kerning = withKerningX[i] - noKerningX; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/ImageHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/ImageHelper.java new file mode 100644 index 000000000..ef4a60aa7 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/ImageHelper.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010-2014 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.helpers; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.imageio.ImageIO; + +/** + * + * @author JPEXS + */ +public class ImageHelper { + + public static BufferedImage read(InputStream input) throws IOException { + return ImageIO.read(input); + } + + public static void write(BufferedImage image, String formatName, OutputStream output) throws IOException { + ImageIO.write(image, formatName, output); + } + + public static void write(BufferedImage image, String formatName, ByteArrayOutputStream output) { + try { + ImageIO.write(image, formatName, output); + } catch (IOException ex) { + Logger.getLogger(ImageHelper.class.getName()).log(Level.SEVERE, null, ex); + } + } +} 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 cc2ad7857..37a99422e 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.importers; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -25,7 +26,6 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import javax.imageio.ImageIO; /** * @@ -36,9 +36,9 @@ public class ImageImporter extends TagImporter { public Tag importImage(ImageTag it, byte[] newData) throws IOException { if (newData[0] == 'B' && newData[1] == 'M') { - BufferedImage b = ImageIO.read(new ByteArrayInputStream(newData)); + BufferedImage b = ImageHelper.read(new ByteArrayInputStream(newData)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageIO.write(b, "PNG", baos); + ImageHelper.write(b, "PNG", baos); newData = baos.toByteArray(); } 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 8f8f84a0b..01bf63dee 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.importers; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineShape2Tag; import com.jpexs.decompiler.flash.tags.DefineShape3Tag; @@ -31,7 +32,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashSet; -import javax.imageio.ImageIO; /** * @@ -43,9 +43,9 @@ public class ShapeImporter { SWF swf = st.getSwf(); if (newData[0] == 'B' && newData[1] == 'M') { - BufferedImage b = ImageIO.read(new ByteArrayInputStream(newData)); + BufferedImage b = ImageHelper.read(new ByteArrayInputStream(newData)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageIO.write(b, "PNG", baos); + ImageHelper.write(b, "PNG", baos); newData = baos.toByteArray(); } 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 efc28e024..6d9511404 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.BasicType; @@ -31,7 +32,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import javax.imageio.ImageIO; public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag { @@ -67,7 +67,7 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag { return cachedImage; } try { - BufferedImage image = ImageIO.read(getImageData()); + BufferedImage image = ImageHelper.read(getImageData()); SerializableImage ret = image == null ? null : new SerializableImage(image); cachedImage = ret; return ret; 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 cb5f3c55f..39f57b027 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.BasicType; @@ -31,7 +32,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import javax.imageio.ImageIO; public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { @@ -54,7 +54,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { @Override public void setImage(byte[] data) throws IOException { if (ImageTag.getImageFormat(data).equals("jpg")) { - SerializableImage image = new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))); + SerializableImage image = new SerializableImage(ImageHelper.read(new ByteArrayInputStream(data))); byte[] ba = new byte[image.getWidth() * image.getHeight()]; for (int i = 0; i < ba.length; i++) { ba[i] = (byte) 255; @@ -94,7 +94,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { } else { stream = new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength()); } - BufferedImage image = ImageIO.read(stream); + BufferedImage image = ImageHelper.read(stream); SerializableImage img = image == null ? null : new SerializableImage(image); if (bitmapAlphaData.length == 0) { return img; 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 3359d6443..8a9b77845 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.BasicType; @@ -31,7 +32,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import javax.imageio.ImageIO; /** * @@ -96,7 +96,7 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag { return cachedImage; } try { - BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength())); + BufferedImage image = ImageHelper.read(new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength())); SerializableImage img = image == null ? null : new SerializableImage(image); if (bitmapAlphaData.getLength() == 0) { return img; 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 90d6a526b..62c471228 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA; @@ -39,7 +40,6 @@ import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.InflaterInputStream; -import javax.imageio.ImageIO; public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { @@ -92,7 +92,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { @Override public void setImage(byte[] data) throws IOException { - SerializableImage image = new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))); + SerializableImage image = new SerializableImage(ImageHelper.read(new ByteArrayInputStream(data))); ALPHABITMAPDATA bitmapData = new ALPHABITMAPDATA(); bitmapFormat = FORMAT_32BIT_ARGB; bitmapWidth = image.getWidth(); 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 a0b46aba2..6e9fe6834 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.BITMAPDATA; @@ -41,7 +42,6 @@ import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.InflaterInputStream; -import javax.imageio.ImageIO; public class DefineBitsLosslessTag extends ImageTag implements AloneTag { @@ -96,7 +96,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { @Override public void setImage(byte[] data) throws IOException { - SerializableImage image = new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))); + SerializableImage image = new SerializableImage(ImageHelper.read(new ByteArrayInputStream(data))); bitmapFormat = FORMAT_24BIT_RGB; bitmapWidth = image.getWidth(); bitmapHeight = image.getHeight(); 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 97fc37ff6..5d008ae88 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -29,7 +30,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import javax.imageio.ImageIO; public class DefineBitsTag extends ImageTag implements TagChangedListener { @@ -89,7 +89,7 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener { } else { baos.write(jpegData.getArray(), jpegData.getPos(), jpegData.getLength()); } - SerializableImage ret = new SerializableImage(ImageIO.read(new ByteArrayInputStream(baos.toByteArray()))); + SerializableImage ret = new SerializableImage(ImageHelper.read(new ByteArrayInputStream(baos.toByteArray()))); cachedImage = ret; return ret; } catch (IOException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index dc0d73cf2..7fbea122f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.KERNINGRECORD; @@ -36,7 +37,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import javax.swing.JPanel; /** * @@ -420,10 +420,10 @@ public class DefineFont2Tag extends FontTag { Font fnt = new Font(fontName, fontStyle, 1024); if (!exists) { fontBoundsTable.add(pos, shp.getBounds()); - fontAdvanceTable.add(pos, (int) getDivider() * Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX())); + fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); } else { fontBoundsTable.set(pos, shp.getBounds()); - fontAdvanceTable.set(pos, (int) getDivider() * Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX())); + fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); } } if (!exists) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 4f2247b37..e5e5aa9e3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.KERNINGRECORD; @@ -40,7 +41,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; -import javax.swing.JPanel; public class DefineFont3Tag extends FontTag { @@ -423,10 +423,10 @@ public class DefineFont3Tag extends FontTag { Font fnt = new Font(fontName, fontStyle, 1024); //Not multiplied with divider as it causes problems to create font with height around 20k if (!exists) { fontBoundsTable.add(pos, shp.getBounds()); - fontAdvanceTable.add(pos, (int) getDivider() * Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX())); + fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); } else { fontBoundsTable.set(pos, shp.getBounds()); - fontAdvanceTable.set(pos, (int) getDivider() * Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX())); + fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); } } if (!exists) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 53fd8d9cb..4d88869c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -360,9 +360,9 @@ public class DefineText2Tag extends TextTag { txtSb.append(c); } } - + txt = txtSb.toString(); - + TEXTRECORD tr = new TEXTRECORD(); textRecords.add(tr); if (fontId > -1) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 6bc309f71..07e82ff58 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -366,7 +366,7 @@ public class DefineTextTag extends TextTag { txtSb.append(c); } } - + txt = txtSb.toString(); TEXTRECORD tr = new TEXTRECORD(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 57ba9cf59..a650f209f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -197,11 +197,11 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable if (tr.styleFlagsHasFont) { curFontId = tr.fontId; } - + if (curFontId != fontId) { continue; } - + for (GLYPHENTRY en : tr.glyphEntries) { if (en == null) { //Currently edited continue; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MissingCharacterHandler.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MissingCharacterHandler.java index 4725b677c..9ac2b7260 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MissingCharacterHandler.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MissingCharacterHandler.java @@ -28,7 +28,7 @@ public class MissingCharacterHandler { public boolean getIgnoreMissingCharacters() { return false; } - + public boolean handle(TextTag textTag, FontTag font, char character) { String fontName = font.getFontNameIntag(); if (!FontTag.installedFontsByFamily.containsKey(fontName)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index 624db6b37..cfbafc118 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags.gfx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.DefineFont2Tag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; @@ -45,7 +46,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; -import javax.swing.JPanel; /** * @@ -180,7 +180,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { } Font fnt = cfont.deriveFont(fontStyle, Math.round(font.nominalSize * d)); - int advance = (int) Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX()); + int advance = (int) Math.round(FontHelper.getFontAdvance(fnt, character)); if (!exists) { font.glyphInfo.add(pos, new GlyphInfoType(code, advance, 0)); font.glyphs.add(pos, new GlyphType(shp.shapeRecords)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 65e082d31..eb5f1ac49 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.tags.base.TextTag; import com.jpexs.decompiler.flash.types.ColorTransform; @@ -41,7 +42,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.swing.JPanel; /** * @@ -243,7 +243,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali } List retList = new ArrayList<>(); Font f = font.deriveFont(fontSize); - GlyphVector v = f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(), "" + character); + GlyphVector v = FontHelper.createGlyphVector(f, character); Shape shp = v.getOutline(); double[] points = new double[6]; int lastX = 0; 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 add52bdf6..6009fce7c 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 @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; import com.jpexs.decompiler.flash.tags.DefineButtonCxformTag; @@ -124,7 +125,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import javax.imageio.ImageIO; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; @@ -1354,11 +1354,7 @@ public class XFLConverter { // do not store the image in cache during xfl conversion imageTag.clearCache(); String format = imageTag.getImageFormat(); - try { - ImageIO.write(image.getBufferedImage(), format.toUpperCase(), baos); - } catch (IOException ex) { - Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); - } + ImageHelper.write(image.getBufferedImage(), format.toUpperCase(), baos); String symbolFile = "bitmap" + symbol.getCharacterId() + "." + imageTag.getImageFormat(); files.put(symbolFile, baos.toByteArray()); String mediaLinkStr = " caches; private List entries; private final JProgressBar progressBar; - private JButton saveButton; - private JButton refreshButton; - private JButton openButton; + private final JButton saveButton; + private final JButton refreshButton; + private final JButton openButton; public LoadFromCacheFrame() { setSize(900, 600); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 6aa93cebe..62d83515c 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1726,12 +1726,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec // "configuration items" for the current replace only private final ConfigurationItem showAgainIgnoreMissingCharacters = new ConfigurationItem<>("showAgainIgnoreMissingCharacters", true, true); private boolean ignoreMissingCharacters = false; - + @Override public boolean getIgnoreMissingCharacters() { return ignoreMissingCharacters; } - + @Override public boolean handle(TextTag textTag, FontTag font, char character) { String fontName = font.getSwf().sourceFontNamesMap.get(font.getFontId()); @@ -1742,9 +1742,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (f == null || !f.canDisplay(character)) { String msg = translate("error.font.nocharacter").replace("%char%", "" + character); logger.log(Level.SEVERE, msg + " FontId: " + font.getCharacterId() + " TextId: " + textTag.getCharacterId()); - ignoreMissingCharacters = View.showConfirmDialog(null, msg, translate("error"), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, - showAgainIgnoreMissingCharacters, + ignoreMissingCharacters = View.showConfirmDialog(null, msg, translate("error"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, + showAgainIgnoreMissingCharacters, ignoreMissingCharacters ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION) == JOptionPane.OK_OPTION; return false; } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java index 618a133cd..4243cf7a6 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java @@ -37,7 +37,7 @@ import jsyntaxpane.SyntaxDocument; public class UndoFixedEditorPane extends JEditorPane { private static final Object setTextLock = new Object(); - + @Override public void setText(String t) { setText(t, getContentType()); diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java index 2001f3445..aa838a930 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java @@ -31,10 +31,10 @@ public class Debugger { private static class DebugHandler extends Thread { - private Socket s; - private int serverPort; + private final Socket s; + private final int serverPort; private static int maxid = 0; - private int id; + private final int id; public boolean finished = false; public DebugHandler(int serverPort, Socket s) { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java index 45a171761..2d8358e2e 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java @@ -167,7 +167,7 @@ public class TagTreeModel implements TreeModel { frames.add(timeline.getFrames().get(i)); } - for (int i = sounds.size() - 1; i >=0 ; i--) { + for (int i = sounds.size() - 1; i >= 0; i--) { TreeItem sound = sounds.get(i); if (sound instanceof SoundStreamHeadTypeTag) { List blocks = ((SoundStreamHeadTypeTag) sound).getBlocks();