diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 56aa3f488..a3b6a1e8c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -52,19 +52,20 @@ import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.exporters.ExportRectangle; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.PathExporter; -import com.jpexs.decompiler.flash.exporters.SVGExporter; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; +import com.jpexs.decompiler.flash.exporters.FontExporter; +import com.jpexs.decompiler.flash.exporters.ImageExporter; +import com.jpexs.decompiler.flash.exporters.MorphShapeExporter; +import com.jpexs.decompiler.flash.exporters.MovieExporter; +import com.jpexs.decompiler.flash.exporters.ShapeExporter; +import com.jpexs.decompiler.flash.exporters.SoundExporter; import com.jpexs.decompiler.flash.exporters.TextExporter; -import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; -import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; -import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings; import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings; @@ -74,19 +75,12 @@ import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings; import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings; import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; -import com.jpexs.decompiler.flash.flv.AUDIODATA; -import com.jpexs.decompiler.flash.flv.FLVOutputStream; -import com.jpexs.decompiler.flash.flv.FLVTAG; -import com.jpexs.decompiler.flash.flv.VIDEODATA; import com.jpexs.decompiler.flash.gui.SWFList; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; import com.jpexs.decompiler.flash.tags.DefineButtonTag; -import com.jpexs.decompiler.flash.tags.DefineSoundTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; -import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.EndTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; @@ -94,7 +88,6 @@ import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; -import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.SymbolClassTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.VideoFrameTag; @@ -106,14 +99,8 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.DrawableTag; -import com.jpexs.decompiler.flash.tags.base.FontTag; -import com.jpexs.decompiler.flash.tags.base.ImageTag; -import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.RemoveTag; -import com.jpexs.decompiler.flash.tags.base.ShapeTag; -import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; -import com.jpexs.decompiler.flash.tags.base.SoundTag; import com.jpexs.decompiler.flash.timeline.Clip; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.timeline.Frame; @@ -128,14 +115,11 @@ import com.jpexs.decompiler.flash.treenodes.ContainerNode; import com.jpexs.decompiler.flash.treenodes.FrameNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; -import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; -import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.filters.BlendComposite; import com.jpexs.decompiler.flash.types.filters.FILTER; -import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.decompiler.flash.xfl.FLAVersion; import com.jpexs.decompiler.flash.xfl.XFLConverter; import com.jpexs.decompiler.graph.Graph; @@ -149,10 +133,6 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.ProgressListener; import com.jpexs.helpers.SerializableImage; import com.jpexs.helpers.utf8.Utf8Helper; -import fontastic.FGlyph; -import fontastic.FPoint; -import fontastic.Fontastic; -import fontastic.PVector; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics2D; @@ -161,7 +141,6 @@ import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; -import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.EOFException; @@ -176,7 +155,6 @@ import java.util.EmptyStackException; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.Stack; @@ -1261,7 +1239,7 @@ public final class SWF implements TreeItem, Timelined { return false; } - public void populateVideoFrames(int streamId, List tags, HashMap output) { + public static void populateVideoFrames(int streamId, List tags, HashMap output) { for (ContainerItem t : tags) { if (t instanceof VideoFrameTag) { output.put(((VideoFrameTag) t).frameNum, (VideoFrameTag) t); @@ -1273,179 +1251,15 @@ public final class SWF implements TreeItem, Timelined { } public void exportMovies(AbortRetryIgnoreHandler handler, String outdir, MovieExportSettings settings) throws IOException { - exportMovies(handler, outdir, tags, settings); + new MovieExporter().exportMovies(handler, outdir, tags, settings); } public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportSettings settings) throws IOException { - exportSounds(handler, outdir, tags, settings); - } - - public byte[] exportSound(SoundTag t, SoundExportMode mode) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - exportSound(baos, t, mode); - return baos.toByteArray(); + new SoundExporter().exportSounds(handler, outdir, tags, settings); } public void exportFonts(AbortRetryIgnoreHandler handler, String outdir, FontExportSettings settings) throws IOException { - exportFonts(handler, outdir, tags, settings); - } - - public List exportFonts(AbortRetryIgnoreHandler handler, String outdir, List tags, final FontExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - for (Tag t : tags) { - File newfile = null; - if (t instanceof FontTag) { - final FontTag st = (FontTag) t; - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".ttf"); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - exportFont(st, settings.mode, file); - } - }, handler).run(); - - ret.add(newfile); - - } - - } - return ret; - } - - public void exportFont(final FontTag t, FontExportMode mode, File file) throws IOException { - List shapes = t.getGlyphShapeTable(); - Fontastic f = new Fontastic(t.getFontName(), file); - String cop = t.getCopyright(); - - f.getEngine().setCopyrightYear(cop == null ? "" : cop); - f.setAuthor(ApplicationInfo.shortApplicationVerName); - f.setVersion("1.0"); - f.setAscender(t.getAscent() / t.getDivider()); - f.setDescender(t.getDescent() / t.getDivider()); - //f.set - - for (int i = 0; i < shapes.size(); i++) { - SHAPE s = shapes.get(i); - final List contours = new ArrayList<>(); - PathExporter seb = new PathExporter(s, new ColorTransform()) { - - private double transformX(double x) { - return Math.ceil((double) (x / t.getDivider())); - } - - private double transformY(double y) { - return -Math.ceil((double) (y / t.getDivider())); - } - - List path = new ArrayList<>(); - private double lastX = 0; - private double lastY = 0; - - @Override - protected void finalizePath() { - FPoint[] points = path.toArray(new FPoint[path.size()]); - if (points.length > 0) { - contours.add(points); - } - path.clear(); - } - - @Override - public void moveTo(double x, double y) { - finalizePath(); - lastX = x; - lastY = y; - path.add(new FPoint(new PVector(transformX(x), transformY(y)))); - } - - @Override - public void lineTo(double x, double y) { - lastX = x; - lastY = y; - path.add(new FPoint(new PVector(transformX(x), transformY(y)))); - } - - @Override - public void curveTo(double controlX, double controlY, double anchorX, double anchorY) { - lastX = anchorX; - lastY = anchorY; - path.add(new FPoint( - new PVector(transformX(anchorX), transformY(anchorY)), - new PVector(transformX(controlX), transformY(controlY)) - )); - - } - }; - seb.export(); - char c = t.glyphToChar(i); - if (contours.isEmpty()) { - continue; - } - if (c == '.') { - continue; - } - final FGlyph g = f.addGlyph(c); - double adv = t.getGlyphAdvance(i); - if (adv != -1) { - g.setAdvanceWidth((int) adv); - } else { - g.setAdvanceWidth(t.getGlyphWidth(i) / t.getDivider() + 100); - } - for (FPoint[] cnt : contours) { - if (cnt.length == 0) { - continue; - } - g.addContour(cnt); - } - - } - f.buildFont(); - } - - public void exportSound(OutputStream fos, SoundTag t, SoundExportMode mode) throws IOException { - if (t instanceof SoundTag) { - SoundTag st = (SoundTag) t; - SoundFormat fmt = st.getSoundFormat(); - int nativeFormat = fmt.getNativeExportFormat(); - - if (nativeFormat == SoundFormat.EXPORT_MP3 && mode.hasMP3()) { - fos.write(st.getRawSoundData()); - } else if ((nativeFormat == SoundFormat.EXPORT_FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) { - if (st instanceof DefineSoundTag) { - FLVOutputStream flv = new FLVOutputStream(fos); - flv.writeHeader(true, false); - flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()))); - } else if (st instanceof SoundStreamHeadTypeTag) { - SoundStreamHeadTypeTag sh = (SoundStreamHeadTypeTag) st; - FLVOutputStream flv = new FLVOutputStream(fos); - flv.writeHeader(true, false); - List blocks = sh.getBlocks(); - - int ms = (int) (1000.0f / ((float) frameRate)); - for (int b = 0; b < blocks.size(); b++) { - byte[] data = blocks.get(b).getData(); - if (st.getSoundFormatId() == 2) { //MP3 - data = Arrays.copyOfRange(data, 4, data.length); - } - flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); - } - } - } else { - fmt.createWav(new ByteArrayInputStream(st.getRawSoundData()), fos); - } - } + new FontExporter().exportFonts(handler, outdir, tags, settings); } private static void writeLE(OutputStream os, long val, int size) throws IOException { @@ -1624,381 +1438,24 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public List exportSounds(AbortRetryIgnoreHandler handler, String outdir, List tags, final SoundExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - for (Tag t : tags) { - File newfile = null; - int id = 0; - if (t instanceof DefineSoundTag) { - id = ((DefineSoundTag) t).soundId; - } - - if (t instanceof SoundTag) { - final SoundTag st = (SoundTag) t; - - String ext = "wav"; - SoundFormat fmt = st.getSoundFormat(); - switch (fmt.getNativeExportFormat()) { - case SoundFormat.EXPORT_MP3: - if (settings.mode.hasMP3()) { - ext = "mp3"; - } - break; - case SoundFormat.EXPORT_FLV: - if (settings.mode.hasFlv()) { - ext = "flv"; - } - break; - } - if (settings.mode == SoundExportMode.FLV) { - ext = "flv"; - } - - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + "." + ext); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - exportSound(os, st, settings.mode); - } - } - }, handler).run(); - - ret.add(newfile); - - } - - } - return ret; - } - - public byte[] exportMovie(DefineVideoStreamTag videoStream, MovieExportMode mode) throws IOException { - HashMap frames = new HashMap<>(); - populateVideoFrames(videoStream.characterID, this.tags, frames); - if (frames.isEmpty()) { - return new byte[0]; - } - - //double ms = 1000.0f / ((float) frameRate); - ByteArrayOutputStream fos = new ByteArrayOutputStream(); - //CopyOutputStream cos = new CopyOutputStream(fos, new FileInputStream("f:\\trunk\\testdata\\xfl\\xfl\\_obj\\streamvideo 7.flv")); - OutputStream tos = fos; - FLVOutputStream flv = new FLVOutputStream(tos); - flv.writeHeader(false, true); - //flv.writeTag(new FLVTAG(0, SCRIPTDATA.onMetaData(ms * frames.size() / 1000.0, videoStream.width, videoStream.height, 0, frameRate, videoStream.codecID, 0, 0, false, 0, fileSize))); - int horizontalAdjustment = 0; - int verticalAdjustment = 0; - for (int i = 0; i < frames.size(); i++) { - VideoFrameTag tag = frames.get(i); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - int frameType = 1; - - if ((videoStream.codecID == DefineVideoStreamTag.CODEC_VP6) - || (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) { - SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), version); - if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) { - sis.readUI24(); //offsetToAlpha - } - int frameMode = (int) sis.readUB(1); - - if (frameMode == 0) { - frameType = 1; //intra - } else { - frameType = 2; //inter - } - sis.readUB(6); //qp - int marker = (int) sis.readUB(1); - if (frameMode == 0) { - int version = (int) sis.readUB(5); - int version2 = (int) sis.readUB(2); - sis.readUB(1);//interlace - if (marker == 1 || version2 == 0) { - sis.readUI16();//offset - } - int dim_y = sis.readUI8(); - int dim_x = sis.readUI8(); - sis.readUI8(); //render_y - sis.readUI8(); //render_x - horizontalAdjustment = (int) (dim_x * Math.ceil(((double) videoStream.width) / (double) dim_x)) - videoStream.width; - verticalAdjustment = (int) (dim_y * Math.ceil(((double) videoStream.height) / (double) dim_y)) - videoStream.height; - - } - - SWFOutputStream sos = new SWFOutputStream(baos, version); - sos.writeUB(4, horizontalAdjustment); - sos.writeUB(4, verticalAdjustment); - } - if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) { - SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), version); - sis.readUB(17);//pictureStartCode - sis.readUB(5); //version - sis.readUB(8); //temporalReference - int pictureSize = (int) sis.readUB(3); //pictureSize - if (pictureSize == 0) { - sis.readUB(8); //customWidth - sis.readUB(8); //customHeight - } - if (pictureSize == 1) { - sis.readUB(16); //customWidth - sis.readUB(16); //customHeight - } - int pictureType = (int) sis.readUB(2); - switch (pictureType) { - case 0: //intra - frameType = 1; //keyframe - break; - case 1://inter - frameType = 2; - break; - case 2: //disposable - frameType = 3; - break; - } - } - - baos.write(tag.videoData); - flv.writeTag(new FLVTAG((int) Math.floor(i * 1000.0f / ((float) frameRate)), new VIDEODATA(frameType, videoStream.codecID, baos.toByteArray()))); - } - return fos.toByteArray(); - } - - public List exportMovies(AbortRetryIgnoreHandler handler, String outdir, List tags, final MovieExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - for (Tag t : tags) { - if (t instanceof DefineVideoStreamTag) { - final DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t; - final File file = new File(outdir + File.separator + ((DefineVideoStreamTag) t).getCharacterExportFileName() + ".flv"); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(exportMovie(videoStream, settings.mode)); - } - } - }, handler).run(); - - } - } - return ret; - } - public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportSettings settings) throws IOException { new TextExporter().exportTexts(handler, outdir, tags, settings); } - public static List exportShapes(AbortRetryIgnoreHandler handler, final String outdir, List tags, final ShapeExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - - for (final Tag t : tags) { - if (t instanceof ShapeTag) { - int characterID = 0; - if (t instanceof CharacterTag) { - characterID = ((CharacterTag) t).getCharacterId(); - } - String ext = "svg"; - if (settings.mode == ShapeExportMode.PNG) { - ext = "png"; - } - - final File file = new File(outdir + File.separator + characterID + "." + ext); - final int fcharacterID = characterID; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - ShapeTag st = (ShapeTag) t; - switch (settings.mode) { - case SVG: - try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(Utf8Helper.getBytes(st.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0))); - } - break; - case PNG: - RECT rect = st.getRect(); - int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); - int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); - SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); - img.fillTransparent(); - Matrix m = new Matrix(); - m.translate(-rect.Xmin, -rect.Ymin); - st.toImage(0, 0, 0, null, 0, img, m, new CXFORMWITHALPHA()); - ImageIO.write(img.getBufferedImage(), "PNG", new FileOutputStream(file)); - break; - } - - } - }, handler).run(); - ret.add(file); - } - } - return ret; - } - - //TODO: implement morphshape export. How to handle 65536 frames? - public static List exportMorphShapes(AbortRetryIgnoreHandler handler, final String outdir, List tags, final MorphShapeExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - - for (final Tag t : tags) { - if (t instanceof MorphShapeTag) { - int characterID = 0; - if (t instanceof CharacterTag) { - characterID = ((CharacterTag) t).getCharacterId(); - } - String ext = "svg"; - - final File file = new File(outdir + File.separator + characterID + "." + ext); - final int fcharacterID = characterID; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - MorphShapeTag mst = (MorphShapeTag) t; - switch (settings.mode) { - case SVG: - try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(Utf8Helper.getBytes(mst.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0))); - } - break; - } - - } - }, handler).run(); - ret.add(file); - } - } - return ret; - } - - public static List exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List tags, BinaryDataExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - - for (final Tag t : tags) { - if (t instanceof DefineBinaryDataTag) { - int characterID = ((DefineBinaryDataTag) t).getCharacterId(); - final File file = new File(outdir + File.separator + characterID + ".bin"); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(((DefineBinaryDataTag) t).binaryData); - } - } - }, handler).run(); - ret.add(file); - } - } - return ret; - } - - public List exportImages(AbortRetryIgnoreHandler handler, String outdir, List tags, final ImageExportSettings settings) throws IOException { - List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - File foutdir = new File(outdir); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - for (final Tag t : tags) { - if (t instanceof ImageTag) { - - String fileFormat = ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH); - if (settings.mode == ImageExportMode.PNG) { - fileFormat = "png"; - } - if (settings.mode == ImageExportMode.JPEG) { - fileFormat = "jpg"; - } - - final File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterId() + "." + fileFormat); - final List ttags = this.tags; - final String ffileFormat = fileFormat; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - - ImageIO.write(((ImageTag) t).getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); - } - }, handler).run(); - ret.add(file); - } - } - return ret; - } - public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportSettings settings) throws IOException { - exportImages(handler, outdir, tags, settings); + new ImageExporter().exportImages(handler, outdir, tags, settings); } public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportSettings settings) throws IOException { - exportShapes(handler, outdir, tags, settings); + new ShapeExporter().exportShapes(handler, outdir, tags, settings); } public void exportMorphShapes(AbortRetryIgnoreHandler handler, String outdir, MorphShapeExportSettings settings) throws IOException { - exportMorphShapes(handler, outdir, tags, settings); + new MorphShapeExporter().exportMorphShapes(handler, outdir, tags, settings); } public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportSettings settings) throws IOException { - exportBinaryData(handler, outdir, tags, settings); + new BinaryDataExporter().exportBinaryData(handler, outdir, tags, settings); } private final HashMap deobfuscated = new HashMap<>(); @@ -2604,18 +2061,6 @@ public final class SWF implements TreeItem, Timelined { if (character instanceof DrawableTag) { DrawableTag drawable = (DrawableTag) character; - int dframe = (time + layer.time) % drawable.getNumFrames(); - if (character instanceof ButtonTag) { - ButtonTag bt = (ButtonTag) character; - dframe = ButtonTag.FRAME_UP; - if (stateUnderCursor == layer) { - if (mouseButton > 0) { - dframe = ButtonTag.FRAME_DOWN; - } else { - dframe = ButtonTag.FRAME_OVER; - } - } - } String assetFileName; Tag drawableTag = (Tag) drawable; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java new file mode 100644 index 000000000..ff9f4dff8 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.Tag; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class BinaryDataExporter { + + public List exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List tags, BinaryDataExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + + for (final Tag t : tags) { + if (t instanceof DefineBinaryDataTag) { + int characterID = ((DefineBinaryDataTag) t).getCharacterId(); + final File file = new File(outdir + File.separator + characterID + ".bin"); + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(((DefineBinaryDataTag) t).binaryData); + } + } + }, handler).run(); + ret.add(file); + } + } + return ret; + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/FontExporter.java new file mode 100644 index 000000000..126c1c5c3 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.ApplicationInfo; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.exporters.shape.PathExporter; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.FontTag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.SHAPE; +import fontastic.FGlyph; +import fontastic.FPoint; +import fontastic.Fontastic; +import fontastic.PVector; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import javax.imageio.ImageIO; + +/** + * + * @author JPEXS + */ +public class FontExporter { + + public List exportFonts(AbortRetryIgnoreHandler handler, String outdir, List tags, final FontExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + for (Tag t : tags) { + File newfile = null; + if (t instanceof FontTag) { + final FontTag st = (FontTag) t; + final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".ttf"); + newfile = file; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + exportFont(st, settings.mode, file); + } + }, handler).run(); + + ret.add(newfile); + + } + + } + return ret; + } + + public void exportFont(final FontTag t, FontExportMode mode, File file) throws IOException { + List shapes = t.getGlyphShapeTable(); + Fontastic f = new Fontastic(t.getFontName(), file); + String cop = t.getCopyright(); + + f.getEngine().setCopyrightYear(cop == null ? "" : cop); + f.setAuthor(ApplicationInfo.shortApplicationVerName); + f.setVersion("1.0"); + f.setAscender(t.getAscent() / t.getDivider()); + f.setDescender(t.getDescent() / t.getDivider()); + //f.set + + for (int i = 0; i < shapes.size(); i++) { + SHAPE s = shapes.get(i); + final List contours = new ArrayList<>(); + PathExporter seb = new PathExporter(s, new ColorTransform()) { + + private double transformX(double x) { + return Math.ceil((double) (x / t.getDivider())); + } + + private double transformY(double y) { + return -Math.ceil((double) (y / t.getDivider())); + } + + List path = new ArrayList<>(); + private double lastX = 0; + private double lastY = 0; + + @Override + protected void finalizePath() { + FPoint[] points = path.toArray(new FPoint[path.size()]); + if (points.length > 0) { + contours.add(points); + } + path.clear(); + } + + @Override + public void moveTo(double x, double y) { + finalizePath(); + lastX = x; + lastY = y; + path.add(new FPoint(new PVector(transformX(x), transformY(y)))); + } + + @Override + public void lineTo(double x, double y) { + lastX = x; + lastY = y; + path.add(new FPoint(new PVector(transformX(x), transformY(y)))); + } + + @Override + public void curveTo(double controlX, double controlY, double anchorX, double anchorY) { + lastX = anchorX; + lastY = anchorY; + path.add(new FPoint( + new PVector(transformX(anchorX), transformY(anchorY)), + new PVector(transformX(controlX), transformY(controlY)) + )); + + } + }; + seb.export(); + char c = t.glyphToChar(i); + if (contours.isEmpty()) { + continue; + } + if (c == '.') { + continue; + } + final FGlyph g = f.addGlyph(c); + double adv = t.getGlyphAdvance(i); + if (adv != -1) { + g.setAdvanceWidth((int) adv); + } else { + g.setAdvanceWidth(t.getGlyphWidth(i) / t.getDivider() + 100); + } + for (FPoint[] cnt : contours) { + if (cnt.length == 0) { + continue; + } + g.addContour(cnt); + } + + } + f.buildFont(); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java new file mode 100644 index 000000000..4197abc71 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +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.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import javax.imageio.ImageIO; + +/** + * + * @author JPEXS + */ +public class ImageExporter { + + public List exportImages(AbortRetryIgnoreHandler handler, String outdir, List tags, final ImageExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + for (final Tag t : tags) { + if (t instanceof ImageTag) { + + String fileFormat = ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH); + if (settings.mode == ImageExportMode.PNG) { + fileFormat = "png"; + } + if (settings.mode == ImageExportMode.JPEG) { + fileFormat = "jpg"; + } + + final File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterId() + "." + fileFormat); + final List ttags = tags; + final String ffileFormat = fileFormat; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + + ImageIO.write(((ImageTag) t).getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); + } + }, handler).run(); + ret.add(file); + } + } + return ret; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java new file mode 100644 index 000000000..0f78a9cda --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; +import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class MorphShapeExporter { + + //TODO: implement morphshape export. How to handle 65536 frames? + public List exportMorphShapes(AbortRetryIgnoreHandler handler, final String outdir, List tags, final MorphShapeExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + + for (final Tag t : tags) { + if (t instanceof MorphShapeTag) { + int characterID = 0; + if (t instanceof CharacterTag) { + characterID = ((CharacterTag) t).getCharacterId(); + } + String ext = "svg"; + + final File file = new File(outdir + File.separator + characterID + "." + ext); + final int fcharacterID = characterID; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + MorphShapeTag mst = (MorphShapeTag) t; + switch (settings.mode) { + case SVG: + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(Utf8Helper.getBytes(mst.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0))); + } + break; + } + + } + }, handler).run(); + ret.add(file); + } + } + return ret; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java new file mode 100644 index 000000000..bc7592281 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings; +import com.jpexs.decompiler.flash.flv.FLVOutputStream; +import com.jpexs.decompiler.flash.flv.FLVTAG; +import com.jpexs.decompiler.flash.flv.VIDEODATA; +import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.VideoFrameTag; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class MovieExporter { + + public List exportMovies(AbortRetryIgnoreHandler handler, String outdir, List tags, final MovieExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + for (Tag t : tags) { + if (t instanceof DefineVideoStreamTag) { + final DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t; + final File file = new File(outdir + File.separator + ((DefineVideoStreamTag) t).getCharacterExportFileName() + ".flv"); + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(exportMovie(videoStream, settings.mode)); + } + } + }, handler).run(); + + } + } + return ret; + } + + public byte[] exportMovie(DefineVideoStreamTag videoStream, MovieExportMode mode) throws IOException { + SWF swf = videoStream.getSwf(); + HashMap frames = new HashMap<>(); + SWF.populateVideoFrames(videoStream.characterID, swf.tags, frames); + if (frames.isEmpty()) { + return new byte[0]; + } + + //double ms = 1000.0f / ((float) frameRate); + ByteArrayOutputStream fos = new ByteArrayOutputStream(); + //CopyOutputStream cos = new CopyOutputStream(fos, new FileInputStream("f:\\trunk\\testdata\\xfl\\xfl\\_obj\\streamvideo 7.flv")); + OutputStream tos = fos; + FLVOutputStream flv = new FLVOutputStream(tos); + flv.writeHeader(false, true); + //flv.writeTag(new FLVTAG(0, SCRIPTDATA.onMetaData(ms * frames.size() / 1000.0, videoStream.width, videoStream.height, 0, frameRate, videoStream.codecID, 0, 0, false, 0, fileSize))); + int horizontalAdjustment = 0; + int verticalAdjustment = 0; + for (int i = 0; i < frames.size(); i++) { + VideoFrameTag tag = frames.get(i); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + int frameType = 1; + + if ((videoStream.codecID == DefineVideoStreamTag.CODEC_VP6) + || (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) { + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), swf.version); + if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) { + sis.readUI24(); //offsetToAlpha + } + int frameMode = (int) sis.readUB(1); + + if (frameMode == 0) { + frameType = 1; //intra + } else { + frameType = 2; //inter + } + sis.readUB(6); //qp + int marker = (int) sis.readUB(1); + if (frameMode == 0) { + int version = (int) sis.readUB(5); + int version2 = (int) sis.readUB(2); + sis.readUB(1);//interlace + if (marker == 1 || version2 == 0) { + sis.readUI16();//offset + } + int dim_y = sis.readUI8(); + int dim_x = sis.readUI8(); + sis.readUI8(); //render_y + sis.readUI8(); //render_x + horizontalAdjustment = (int) (dim_x * Math.ceil(((double) videoStream.width) / (double) dim_x)) - videoStream.width; + verticalAdjustment = (int) (dim_y * Math.ceil(((double) videoStream.height) / (double) dim_y)) - videoStream.height; + + } + + SWFOutputStream sos = new SWFOutputStream(baos, swf.version); + sos.writeUB(4, horizontalAdjustment); + sos.writeUB(4, verticalAdjustment); + } + if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) { + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), swf.version); + sis.readUB(17);//pictureStartCode + sis.readUB(5); //version + sis.readUB(8); //temporalReference + int pictureSize = (int) sis.readUB(3); //pictureSize + if (pictureSize == 0) { + sis.readUB(8); //customWidth + sis.readUB(8); //customHeight + } + if (pictureSize == 1) { + sis.readUB(16); //customWidth + sis.readUB(16); //customHeight + } + int pictureType = (int) sis.readUB(2); + switch (pictureType) { + case 0: //intra + frameType = 1; //keyframe + break; + case 1://inter + frameType = 2; + break; + case 2: //disposable + frameType = 3; + break; + } + } + + baos.write(tag.videoData); + flv.writeTag(new FLVTAG((int) Math.floor(i * 1000.0f / ((float) swf.frameRate)), new VIDEODATA(frameType, videoStream.codecID, baos.toByteArray()))); + } + return fos.toByteArray(); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java new file mode 100644 index 000000000..9c3f4e041 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; +import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.helpers.SerializableImage; +import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.imageio.ImageIO; + +/** + * + * @author JPEXS + */ +public class ShapeExporter { + + public List exportShapes(AbortRetryIgnoreHandler handler, final String outdir, List tags, final ShapeExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + + for (final Tag t : tags) { + if (t instanceof ShapeTag) { + int characterID = 0; + if (t instanceof CharacterTag) { + characterID = ((CharacterTag) t).getCharacterId(); + } + String ext = "svg"; + if (settings.mode == ShapeExportMode.PNG) { + ext = "png"; + } + + final File file = new File(outdir + File.separator + characterID + "." + ext); + final int fcharacterID = characterID; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + ShapeTag st = (ShapeTag) t; + switch (settings.mode) { + case SVG: + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(Utf8Helper.getBytes(st.toSVG(new SVGExporterContext(outdir, "assets_" + fcharacterID), -2, new CXFORMWITHALPHA(), 0))); + } + break; + case PNG: + RECT rect = st.getRect(); + int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); + int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); + SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); + img.fillTransparent(); + Matrix m = new Matrix(); + m.translate(-rect.Xmin, -rect.Ymin); + st.toImage(0, 0, 0, null, 0, img, m, new CXFORMWITHALPHA()); + ImageIO.write(img.getBufferedImage(), "PNG", new FileOutputStream(file)); + break; + } + + } + }, handler).run(); + ret.add(file); + } + } + return ret; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java new file mode 100644 index 000000000..6cd9f3826 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters; + +import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import com.jpexs.decompiler.flash.RetryTask; +import com.jpexs.decompiler.flash.RunnableIOEx; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.flv.AUDIODATA; +import com.jpexs.decompiler.flash.flv.FLVOutputStream; +import com.jpexs.decompiler.flash.flv.FLVTAG; +import com.jpexs.decompiler.flash.tags.DefineSoundTag; +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.SoundFormat; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class SoundExporter { + + public List exportSounds(AbortRetryIgnoreHandler handler, String outdir, List tags, final SoundExportSettings settings) throws IOException { + List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + File foutdir = new File(outdir); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + for (Tag t : tags) { + File newfile = null; + int id = 0; + if (t instanceof DefineSoundTag) { + id = ((DefineSoundTag) t).soundId; + } + + if (t instanceof SoundTag) { + final SoundTag st = (SoundTag) t; + + String ext = "wav"; + SoundFormat fmt = st.getSoundFormat(); + switch (fmt.getNativeExportFormat()) { + case SoundFormat.EXPORT_MP3: + if (settings.mode.hasMP3()) { + ext = "mp3"; + } + break; + case SoundFormat.EXPORT_FLV: + if (settings.mode.hasFlv()) { + ext = "flv"; + } + break; + } + if (settings.mode == SoundExportMode.FLV) { + ext = "flv"; + } + + final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + "." + ext); + newfile = file; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { + exportSound(os, st, settings.mode); + } + } + }, handler).run(); + + ret.add(newfile); + + } + + } + return ret; + } + + public byte[] exportSound(SoundTag t, SoundExportMode mode) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + exportSound(baos, t, mode); + return baos.toByteArray(); + } + + public void exportSound(OutputStream fos, SoundTag st, SoundExportMode mode) throws IOException { + SoundFormat fmt = st.getSoundFormat(); + int nativeFormat = fmt.getNativeExportFormat(); + + if (nativeFormat == SoundFormat.EXPORT_MP3 && mode.hasMP3()) { + fos.write(st.getRawSoundData()); + } else if ((nativeFormat == SoundFormat.EXPORT_FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) { + if (st instanceof DefineSoundTag) { + FLVOutputStream flv = new FLVOutputStream(fos); + flv.writeHeader(true, false); + flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()))); + } else if (st instanceof SoundStreamHeadTypeTag) { + SoundStreamHeadTypeTag sh = (SoundStreamHeadTypeTag) st; + FLVOutputStream flv = new FLVOutputStream(fos); + flv.writeHeader(true, false); + List blocks = sh.getBlocks(); + + int ms = (int) (1000.0f / ((float) ((Tag) st).getSwf().frameRate)); + for (int b = 0; b < blocks.size(); b++) { + byte[] data = blocks.get(b).getData(); + if (st.getSoundFormatId() == 2) { //MP3 + data = Arrays.copyOfRange(data, 4, data.length); + } + flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); + } + } + } else { + fmt.createWav(new ByteArrayInputStream(st.getRawSoundData()), fos); + } + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java similarity index 94% rename from trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java index a268a53e0..531441052 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; import com.jpexs.decompiler.flash.types.RECT; import java.awt.geom.Rectangle2D; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java similarity index 96% rename from trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java index 01edf6521..bef1f2075 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Matrix.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; import com.jpexs.decompiler.flash.types.MATRIX; import java.awt.geom.AffineTransform; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java similarity index 92% rename from trunk/src/com/jpexs/decompiler/flash/exporters/Point.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java index 28c3794b0..9d984708c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Point.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/PointInt.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/PointInt.java similarity index 92% rename from trunk/src/com/jpexs/decompiler/flash/exporters/PointInt.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/PointInt.java index d60ccb952..5972cc0e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/PointInt.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/PointInt.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java similarity index 95% rename from trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporter.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java index a77c80934..828a2ec4f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java @@ -14,8 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporterContext.java b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporterContext.java similarity index 92% rename from trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporterContext.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporterContext.java index b281053b0..ad53fcb8c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporterContext.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporterContext.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.commonshape; import com.jpexs.decompiler.flash.tags.Tag; import java.util.HashMap; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/CurvedMorphEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/CurvedMorphEdge.java index 73e8c9142..322ee75c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/CurvedMorphEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/CurvedMorphEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.morphshape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java index 857bca521..6ebfd78dd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/DefaultSVGMorphShapeExporter.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphEdge.java index ceaf00d8b..e50c64307 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.morphshape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphShapeExporter.java index 055f136b9..2efc56f15 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/IMorphShapeExporter.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.morphshape; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java index 40744beb9..0621c50e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/MorphShapeExporterBase.java @@ -16,8 +16,8 @@ */ package com.jpexs.decompiler.flash.exporters.morphshape; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java index a2f4e3c38..307535e07 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/SVGMorphShapeExporter.java @@ -17,8 +17,8 @@ package com.jpexs.decompiler.flash.exporters.morphshape; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.ColorTransform; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/StraightMorphEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/StraightMorphEdge.java index 8283c459f..83f76b764 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/StraightMorphEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/morphshape/StraightMorphEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.morphshape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java similarity index 96% rename from trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index 11570a521..7f79d61a3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java @@ -14,8 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.shape; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.shape.ShapeExporterBase; import com.jpexs.decompiler.flash.tags.Tag; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/CurvedEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/CurvedEdge.java index bfc6feb25..4fdb7fff8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/CurvedEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/CurvedEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.shape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java index 27b93580c..a65f7f298 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/DefaultSVGShapeExporter.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IEdge.java index 4bb62e1fb..368033c77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.shape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IShapeExporter.java index 8adcef870..47c8eab42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/IShapeExporter.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.shape; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; import com.jpexs.decompiler.flash.types.RGB; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/PathExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java similarity index 93% rename from trunk/src/com/jpexs/decompiler/flash/exporters/PathExporter.java rename to trunk/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java index 3e284502e..07fbe1827 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/PathExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/PathExporter.java @@ -14,8 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.exporters; +package com.jpexs.decompiler.flash.exporters.shape; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.shape.ShapeExporterBase; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GRADRECORD; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java index 312845dd7..ccc55ca9f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/SVGShapeExporter.java @@ -17,8 +17,8 @@ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.types.ColorTransform; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java index e68338e69..381e41673 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/ShapeExporterBase.java @@ -16,8 +16,8 @@ */ package com.jpexs.decompiler.flash.exporters.shape; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.FILLSTYLE; import com.jpexs.decompiler.flash.types.FOCALGRADIENT; diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/StraightEdge.java b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/StraightEdge.java index 3982cf407..81309d856 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/shape/StraightEdge.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/shape/StraightEdge.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.exporters.shape; -import com.jpexs.decompiler.flash.exporters.PointInt; +import com.jpexs.decompiler.flash.exporters.commonshape.PointInt; /** * diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index fdd5ae586..d2094572d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.AppStrings; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 261914386..417ce0627 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -26,6 +26,13 @@ import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; +import com.jpexs.decompiler.flash.exporters.FontExporter; +import com.jpexs.decompiler.flash.exporters.ImageExporter; +import com.jpexs.decompiler.flash.exporters.MorphShapeExporter; +import com.jpexs.decompiler.flash.exporters.MovieExporter; +import com.jpexs.decompiler.flash.exporters.ShapeExporter; +import com.jpexs.decompiler.flash.exporters.SoundExporter; import com.jpexs.decompiler.flash.exporters.TextExporter; import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; @@ -1274,21 +1281,21 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } final ScriptExportMode scriptMode = export.getValue(ScriptExportMode.class); - ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images, + ret.addAll(new ImageExporter().exportImages(handler, selFile + File.separator + "images", images, new ImageExportSettings(export.getValue(ImageExportMode.class)))); - ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes, + ret.addAll(new ShapeExporter().exportShapes(handler, selFile + File.separator + "shapes", shapes, new ShapeExportSettings(export.getValue(ShapeExportMode.class)))); - ret.addAll(SWF.exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, + ret.addAll(new MorphShapeExporter().exportMorphShapes(handler, selFile + File.separator + "morphshapes", morphshapes, new MorphShapeExportSettings(export.getValue(MorphShapeExportMode.class)))); ret.addAll(new TextExporter().exportTexts(handler, selFile + File.separator + "texts", texts, new TextExportSettings(export.getValue(TextExportMode.class), Configuration.textExportSingleFile.get()))); - ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies, + ret.addAll(new MovieExporter().exportMovies(handler, selFile + File.separator + "movies", movies, new MovieExportSettings(export.getValue(MovieExportMode.class)))); - ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, + ret.addAll(new SoundExporter().exportSounds(handler, selFile + File.separator + "sounds", sounds, new SoundExportSettings(export.getValue(SoundExportMode.class)))); - ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, + ret.addAll(new BinaryDataExporter().exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, new BinaryDataExportSettings(export.getValue(BinaryDataExportMode.class)))); - ret.addAll(swf.exportFonts(handler, selFile + File.separator + "fonts", fonts, + ret.addAll(new FontExporter().exportFonts(handler, selFile + File.separator + "fonts", fonts, new FontExportSettings(export.getValue(FontExportMode.class)))); for (Entry> entry : frames.entrySet()) { @@ -1661,7 +1668,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec String[] records = textArr[1].split(recordSeparator); result.put(id, records); } else { - View.showMessageDialog(null, translate("error.text.import"), translate("error"), JOptionPane.ERROR_MESSAGE); + if (View.showConfirmDialog(this, translate("error.text.import"), translate("error"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { + return null; + } } } return result; @@ -1680,14 +1689,16 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (textsFile.exists()) { String texts = Helper.readTextFile(textsFile.getPath()); Map records = splitTextRecords(texts); - for (int characterId : records.keySet()) { - for (Tag tag : swf.tags) { - if (tag instanceof TextTag) { - TextTag textTag = (TextTag) tag; - if (textTag.getCharacterId() == characterId) { - String[] currentRecords = records.get(characterId); - saveText(textTag, currentRecords[0], null); - break; + if (records != null) { + for (int characterId : records.keySet()) { + for (Tag tag : swf.tags) { + if (tag instanceof TextTag) { + TextTag textTag = (TextTag) tag; + if (textTag.getCharacterId() == characterId) { + String[] currentRecords = records.get(characterId); + saveText(textTag, currentRecords[0], null); + break; + } } } } @@ -1698,15 +1709,17 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (textsFile.exists()) { String texts = Helper.readTextFile(textsFile.getPath()); Map records = splitTextRecords(texts); - for (int characterId : records.keySet()) { - for (Tag tag : swf.tags) { - if (tag instanceof TextTag) { - TextTag textTag = (TextTag) tag; - if (textTag.getCharacterId() == characterId) { - String[] currentRecords = records.get(characterId); - String text = textTag.getFormattedText(); - saveText(textTag, text, currentRecords); - break; + if (records != null) { + for (int characterId : records.keySet()) { + for (Tag tag : swf.tags) { + if (tag instanceof TextTag) { + TextTag textTag = (TextTag) tag; + if (textTag.getCharacterId() == characterId) { + String[] currentRecords = records.get(characterId); + String text = textTag.getFormattedText(); + saveText(textTag, text, currentRecords); + break; + } } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java index d9f4bffb7..86fbf2ec5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 6e135a7f9..d822769ee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -19,8 +19,8 @@ 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.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.TextTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index 0b89689bd..0884353d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -19,11 +19,11 @@ 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.exporters.BitmapExporter; -import com.jpexs.decompiler.flash.exporters.ExportRectangle; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 32f495702..76f75a257 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -19,11 +19,11 @@ 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.exporters.BitmapExporter; -import com.jpexs.decompiler.flash.exporters.ExportRectangle; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.CharacterTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 40fdaff5f..9a0ba19cf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -21,8 +21,8 @@ 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.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.Container; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 1955f6c39..fa99fbea8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -19,8 +19,8 @@ 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.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.TextTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index e6fdcfa00..ee421c8f0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -20,8 +20,8 @@ import com.jpexs.decompiler.flash.AppStrings; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.TextTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java index 42e811305..3f49a5455 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java @@ -17,8 +17,8 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.timeline.DepthState; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java index a18a06c13..900ba6121 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/DrawableTag.java @@ -16,8 +16,8 @@ */ package com.jpexs.decompiler.flash.tags.base; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.helpers.SerializableImage; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 9e4df895e..5ba4ccc7d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.tags.DefineFontNameTag; import com.jpexs.decompiler.flash.tags.DefineText2Tag; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java index 68d750af0..fe8836673 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -17,11 +17,11 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.BitmapExporter; -import com.jpexs.decompiler.flash.exporters.ExportRectangle; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; -import com.jpexs.decompiler.flash.exporters.SVGExporterContext; +import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporterContext; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.ColorTransform; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 91a3ba830..d6d92e95e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -17,9 +17,9 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.BitmapExporter; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.exporters.SVGExporter; +import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.text.ParseException; diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 2d6fc3e80..b737808a7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java b/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java index e62a097d4..757aaa9b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.types; -import com.jpexs.decompiler.flash.exporters.PathExporter; +import com.jpexs.decompiler.flash.exporters.shape.PathExporter; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 5b3a6b852..10a917bd7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.types.shaperecords; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.exporters.BitmapExporter; -import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.tags.base.TextTag; diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 26bab089b..b94202263 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.MovieExporter; +import com.jpexs.decompiler.flash.exporters.SoundExporter; import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; @@ -1500,7 +1502,7 @@ public class XFLConverter { SoundFormat fmt = st.getSoundFormat(); byte[] data = new byte[0]; try { - data = swf.exportSound(st, SoundExportMode.MP3_WAV); + data = new SoundExporter().exportSound(st, SoundExportMode.MP3_WAV); } catch (IOException ex) { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); } @@ -1547,7 +1549,7 @@ public class XFLConverter { byte[] data = new byte[0]; try { - data = swf.exportMovie(video, MovieExportMode.FLV); + data = new MovieExporter().exportMovie(video, MovieExportMode.FLV); } catch (IOException ex) { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); }