diff --git a/trunk/src/com/jpexs/decompiler/flash/Main.java b/trunk/src/com/jpexs/decompiler/flash/Main.java index 71350cecb..ce4587028 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/Main.java @@ -406,8 +406,8 @@ public class Main { System.out.println(" ...opens SWF file with the decompiler GUI"); System.out.println(" 3) -proxy (-PXXX)"); System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. "); - System.out.println(" 4) -export (as|pcode|image) outdirectory infile"); - System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument) or images"); + System.out.println(" 4) -export (as|pcode|image|shape) outdirectory infile"); + System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument), images or shapes"); System.out.println(" 5) -dumpSWF infile"); System.out.println(" ...dumps list of SWF tags to console"); System.out.println(" 6) -compress infile outfile"); @@ -533,8 +533,10 @@ public class Main { if (!exportFormat.toLowerCase().equals("as")) { if (!exportFormat.toLowerCase().equals("pcode")) { if (!exportFormat.toLowerCase().equals("image")) { - System.err.println("Invalid export format:" + exportFormat); - badArguments(); + if (!exportFormat.toLowerCase().equals("shape")) { + System.err.println("Invalid export format:" + exportFormat); + badArguments(); + } } } } @@ -560,7 +562,10 @@ public class Main { if (exportFormat.equals("image")) { exfile.exportImages(outDir.getAbsolutePath()); exportOK = true; - } else if (exportFormat.equals("as") || exportFormat.equals("pcode")) { + } else if (exportFormat.equals("shape")) { + exfile.exportShapes(outDir.getAbsolutePath()); + exportOK = true; + }else if (exportFormat.equals("as") || exportFormat.equals("pcode")) { exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode")); } else { exportOK = false; diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 540cf421c..845e2bf56 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.tags.DefineBitsTag; import com.jpexs.decompiler.flash.tags.DoABCTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; 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.RECT; import java.io.*; import java.util.ArrayList; @@ -432,6 +434,30 @@ public class SWF { return false; } + public static void exportShapes(String outdir,List tags) throws IOException{ + for (Tag t : tags) { + if(t instanceof ShapeTag){ + int characterID=0; + if(t instanceof CharacterTag){ + characterID=((CharacterTag)t).getCharacterID(); + } + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + characterID + ".svg"); + fos.write(((ShapeTag)t).toSVG().getBytes()); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } + } + } + } + public static void exportImages(String outdir, List tags, JPEGTablesTag jtt) throws IOException { for (Tag t : tags) { if ((t instanceof DefineBitsJPEG2Tag) || (t instanceof DefineBitsJPEG3Tag) || (t instanceof DefineBitsJPEG4Tag)) { @@ -504,6 +530,9 @@ public class SWF { } } exportImages(outdir, tags, jtt); - + } + + public void exportShapes(String outdir) throws IOException { + exportShapes(outdir, tags); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index d99c89509..35f8189c4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -54,6 +54,7 @@ import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Container; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; @@ -188,11 +189,16 @@ public class MainFrame extends JFrame implements ActionListener { miExportImages.setIcon(new ImageIcon(View.loadImage("com/jpexs/decompiler/flash/gui/graphics/image16.png"))); miExportImages.setActionCommand("EXPORTIMAGES"); miExportImages.addActionListener(this); + + JMenuItem miExportShapes = new JMenuItem("Shapes..."); + miExportShapes.setIcon(new ImageIcon(View.loadImage("com/jpexs/decompiler/flash/gui/graphics/shape16.png"))); + miExportShapes.setActionCommand("EXPORTSHAPES"); + miExportShapes.addActionListener(this); menuExportAll.add(miExportAllAS); menuExportAll.add(miExportAllPCode); menuExportAll.add(miExportImages); - + menuExportAll.add(miExportShapes); JMenu menuExportSel = new JMenu("Export selection"); JMenuItem miExportSelAS = new JMenuItem("ActionScript..."); @@ -209,11 +215,16 @@ public class MainFrame extends JFrame implements ActionListener { miExportSelImages.setIcon(new ImageIcon(View.loadImage("com/jpexs/decompiler/flash/gui/graphics/image16.png"))); miExportSelImages.setActionCommand("EXPORTIMAGESSEL"); miExportSelImages.addActionListener(this); + + JMenuItem miExportSelShapes = new JMenuItem("Shapes..."); + miExportSelShapes.setIcon(new ImageIcon(View.loadImage("com/jpexs/decompiler/flash/gui/graphics/shape16.png"))); + miExportSelShapes.setActionCommand("EXPORTSHAPESSEL"); + miExportSelShapes.addActionListener(this); menuExportSel.add(miExportSelAS); menuExportSel.add(miExportSelPCode); menuExportSel.add(miExportSelImages); - + menuExportSel.add(miExportSelShapes); menuFile.add(miOpen); menuFile.add(miSave); @@ -698,6 +709,7 @@ public class MainFrame extends JFrame implements ActionListener { final boolean isPcode = e.getActionCommand().startsWith("EXPORTPCODE"); final boolean onlySel = e.getActionCommand().endsWith("SEL"); final boolean images = e.getActionCommand().startsWith("EXPORTIMAGES"); + final boolean shapes = e.getActionCommand().startsWith("EXPORTSHAPES"); (new Thread() { @Override public void run() { @@ -722,6 +734,15 @@ public class MainFrame extends JFrame implements ActionListener { } SWF.exportImages(selFile, list, jtt); } + } else if(shapes){ + List list = new ArrayList(); + Object lob[] = shapesTagPanel.tagList.getSelectedValues(); + for (Object o : lob) { + if (o instanceof ShapeTag) { + list.add((Tag) o); + } + } + SWF.exportShapes(selFile, list); } else if (abcPanel != null) { List tlsList = abcPanel.classTree.getSelectedScripts(); if (tlsList.isEmpty()) { @@ -746,11 +767,14 @@ public class MainFrame extends JFrame implements ActionListener { } else { if (images) { Main.swf.exportImages(selFile); + } else if(shapes) { + Main.swf.exportShapes(selFile); } else { Main.swf.exportActionScript(selFile, isPcode); } } } catch (Exception ignored) { + ignored.printStackTrace(); JOptionPane.showMessageDialog(null, "Cannot write to the file"); } Main.stopWork(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java index 33c5e0afa..257597899 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java @@ -20,18 +20,25 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; -public class DefineShape2Tag extends CharacterTag implements BoundedTag, AloneTag { +public class DefineShape2Tag extends CharacterTag implements BoundedTag, AloneTag,ShapeTag { public int shapeId; public RECT shapeBounds; public SHAPEWITHSTYLE shapes; + + @Override + public String toSVG() { + return shapes.toSVG(2); + } + @Override public int getCharacterID() { return shapeId; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index 2e28c2705..96bd3e45d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -20,13 +20,14 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; -public class DefineShape3Tag extends CharacterTag implements BoundedTag, AloneTag { +public class DefineShape3Tag extends CharacterTag implements BoundedTag, AloneTag,ShapeTag { public int shapeId; public RECT shapeBounds; @@ -36,6 +37,11 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, AloneTa public RECT getRect(HashMap characters) { return shapeBounds; } + + @Override + public String toSVG() { + return shapes.toSVG(3); + } @Override public int getCharacterID() { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index efac805e6..1b3a85047 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -20,13 +20,14 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; -public class DefineShape4Tag extends CharacterTag implements BoundedTag, AloneTag { +public class DefineShape4Tag extends CharacterTag implements BoundedTag, AloneTag,ShapeTag { public int shapeId; public RECT shapeBounds; @@ -36,6 +37,11 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, AloneTa public boolean usesScalingStrokes; public SHAPEWITHSTYLE shapes; + @Override + public String toSVG() { + return shapes.toSVG(4); + } + @Override public int getCharacterID() { return shapeId; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index 327212b23..86826aba6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -20,13 +20,14 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; -public class DefineShapeTag extends CharacterTag implements BoundedTag, AloneTag { +public class DefineShapeTag extends CharacterTag implements BoundedTag, AloneTag,ShapeTag { public int shapeId; public RECT shapeBounds; @@ -49,4 +50,10 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, AloneTag public int getCharacterID() { return shapeId; } + + @Override + public String toSVG() { + return shapes.toSVG(1); + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java new file mode 100644 index 000000000..2eab188ef --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010-2013 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.tags.base; + +/** + * + * @author JPEXS + */ +public interface ShapeTag { + public String toSVG(); +}