diff --git a/trunk/lib/FlashPlayer.exe b/trunk/lib/FlashPlayer.exe index 0f5dc1e0a..6d168a784 100644 Binary files a/trunk/lib/FlashPlayer.exe and b/trunk/lib/FlashPlayer.exe differ diff --git a/trunk/libsrc/FlashPlayer/uMain.dcu b/trunk/libsrc/FlashPlayer/uMain.dcu index e74554a12..9faed8f2a 100644 Binary files a/trunk/libsrc/FlashPlayer/uMain.dcu and b/trunk/libsrc/FlashPlayer/uMain.dcu differ diff --git a/trunk/libsrc/FlashPlayer/uMain.dfm b/trunk/libsrc/FlashPlayer/uMain.dfm index 7a4b131e6..a0629fa85 100644 --- a/trunk/libsrc/FlashPlayer/uMain.dfm +++ b/trunk/libsrc/FlashPlayer/uMain.dfm @@ -1,6 +1,6 @@ object frmMain: TfrmMain - Left = 506 - Top = 161 + Left = 625 + Top = 484 Width = 1381 Height = 811 Caption = 'FFDec Flash Player' @@ -648,26 +648,6 @@ object frmMain: TfrmMain OnCreate = FormCreate PixelsPerInch = 120 TextHeight = 16 - object flaPreview: TShockwaveFlash - Left = 98 - Top = 34 - Width = 151 - Height = 135 - TabOrder = 0 - OnReadyStateChange = flaPreviewReadyStateChange - ControlData = { - 67556655000B00007C0C00002A0B000008000200000000000800040000002D00 - 00000800040000002D00000008000E000000570069006E0064006F0077000000 - 0800060000002D00310000000800060000002D003100000008000A0000004800 - 690067006800000008000200000000000800060000002D003100000008000000 - 000008000E00000061006C007700610079007300000008001000000053006800 - 6F00770041006C006C0000000800040000003000000008000400000030000000 - 080002000000000008000000000008000200000000000D000000000000000000 - 0000000000000000080004000000310000000800040000003000000008000000 - 00000800040000003000000008000800000061006C006C00000008000C000000 - 660061006C0073006500000008000C000000660061006C007300650000000800 - 060000002D0031000000} - end object tmrWatchDog: TTimer OnTimer = tmrWatchDogTimer Left = 16 diff --git a/trunk/libsrc/FlashPlayer/uMain.pas b/trunk/libsrc/FlashPlayer/uMain.pas index 78be0bec2..aa760ed91 100644 --- a/trunk/libsrc/FlashPlayer/uMain.pas +++ b/trunk/libsrc/FlashPlayer/uMain.pas @@ -8,15 +8,12 @@ uses type TfrmMain = class(TForm) - flaPreview: TShockwaveFlash; tmrWatchDog: TTimer; procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure tmrWatchDogTimer(Sender: TObject); - procedure flaPreviewReadyStateChange(ASender: TObject; - newState: Integer); private { Private declarations } public @@ -29,9 +26,11 @@ type flashFile:string; w:integer; h:integer; + bgColor:TColor; procedure Execute; override; procedure displaySWF; procedure setPos; + procedure setBGColor; end; TBuf = array[0..255] of byte; @@ -39,6 +38,7 @@ var frmMain: TfrmMain; k:String; t:TPipeThread; + flaPreview: TShockwaveFlash; target:HWND=0; implementation @@ -65,43 +65,31 @@ end; procedure TPipeThread.displaySWF(); begin windows.SetParent(frmMain.Handle,target); - frmMain.flaPreview.Stop; - frmMain.flaPreview.Movie := ''; - frmMain.flaPreview.Left:=0; - frmMain.flaPreview.Top:=0; - frmMain.flaPreview.Width:=self.w; - frmMain.flaPreview.Height:=self.h; - frmMain.flaPreview.AllowScriptAccess:='always'; + flaPreview.Stop; + flaPreview.Movie := ''; + flaPreview.Free; + flaPreview := nil; + flaPreview := TShockwaveFlash.Create(frmMain); + flaPreview.Left:=0; + flaPreview.Top:=0; + flaPreview.Width:=self.w; + flaPreview.Height:=self.h; frmMain.Caption:='set movie:'+flashFile; - frmMain.Repaint(); - - frmMain.flaPreview.Playing := true; - frmMain.flaPreview.Movie:=flashFile; - frmMain.flaPreview.Play; + flaPreview.Parent := frmMain; + flaPreview.Movie:=flashFile; end; +procedure TPipeThread.setBGColor(); +begin + frmMain.Color := self.bgColor; +end; procedure TPipeThread.setPos(); -var movie:WideString; begin - - movie:=frmMain.flaPreview.Movie; - SetWindowPos(frmMain.Handle,0,0,0,self.w,self.h,SWP_SHOWWINDOW); - frmMain.flaPreview.Movie:=''; - frmMain.flaPreview.Playing := false; - frmMain.flaPreview.Parent:=nil; - frmMain.flaPreview.Left:=0; - frmMain.flaPreview.Top:=0; - frmMain.flaPreview.Width:=self.w; - frmMain.flaPreview.Height:=self.h; - frmMain.flaPreview.Parent:=frmMain; - frmMain.flaPreview.AllowScriptAccess:='always'; - frmMain.flaPreview.Movie:=movie; - frmMain.flaPreview.Play; - frmMain.Caption:=''+inttostr(self.w)+'x'+inttostr(self.h); - +SetWindowPos(frmMain.Handle,0,0,0,self.w,self.h,SWP_SHOWWINDOW); +displaySWF(); end; procedure TPipeThread.Execute(); @@ -147,6 +135,12 @@ begin self.h:=buffer[2]*256+buffer[3]; Synchronize(setPos); end; + if(cmd=3) then + begin + ReadFile(pipe,buffer,3,numBytesRead,nil); + self.bgColor := RGB(buffer[0],buffer[1],buffer[2]); + Synchronize(setBGColor); + end; end until numBytesRead<=0; CloseHandle(pipe); @@ -158,34 +152,41 @@ end; procedure TfrmMain.FormActivate(Sender: TObject); begin - if(ParamCount>=2) then - begin - ShowWindow(Application.Handle, SW_HIDE) ; + + + +if(ParamCount>=2) then + begin + flaPreview.Parent := frmMain; + + ShowWindow(Application.Handle, SW_HIDE) ; SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ; ShowWindow(Application.Handle, SW_SHOW); - SetForegroundWindow(HWND(strtoint(ParamStr(2)))); frmMain.Caption:='FlashPlayerWindow_'+ParamStr(2); Application.Title:='FlashPlayerWindow_'+ParamStr(2); target:=HWND(strtoint(ParamStr(1))); + SetWindowLong(frmMain.Handle, GWL_STYLE, 0); ShowWindow(frmMain.Handle, SW_SHOW); + frmMain.Left:=0; frmMain.Top:=0; windows.SetParent(frmMain.Handle,target); t:=TPipeThread.Create(true); t.Resume; - end; + end; end; procedure TfrmMain.FormCreate(Sender: TObject); begin if(ParamCount>=2) then begin - + flaPreview := TShockwaveFlash.Create(frmMain); + flaPreview.BackgroundColor:=-1; end; end; @@ -205,14 +206,4 @@ begin end; end; -procedure TfrmMain.flaPreviewReadyStateChange(ASender: TObject; - newState: Integer); -begin -if newState = 4 then - begin - frmMain.flaPreview.Playing := True; - frmMain.flaPreview.Play; - end; -end; - end. diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index f2ec35a90..5cc2d78bf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -1228,7 +1228,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel } else { JPanel swtPanel = new JPanel(new BorderLayout()); swtPanel.add(new JLabel("
" + translate("notavailonthisplatform") + "
", JLabel.CENTER), BorderLayout.CENTER); - swtPanel.setBackground(Color.white); + swtPanel.setBackground(View.DEFAULT_BACKGROUND_COLOR); leftComponent = swtPanel; } @@ -1296,16 +1296,6 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel shapesCard.add(previewPanel, BorderLayout.CENTER); displayPanel.add(shapesCard, CARDDRAWPREVIEWPANEL); - Color backgroundColor = Color.white; - if (swf != null) { - for (Tag t : swf.tags) { - if (t instanceof SetBackgroundColorTag) { - backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor(); - break; - } - } - } - View.swfBackgroundColor = backgroundColor; swfPreviewPanel = new SWFPreviwPanel(); displayPanel.add(swfPreviewPanel, CARDSWFPREVIEWPANEL); @@ -2230,7 +2220,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel case "SELECTCOLOR": Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectcolor.title"), View.swfBackgroundColor); if (newColor != null) { - View.swfBackgroundColor = newColor; + View.swfBackgroundColor = newColor; reload(true); } break; @@ -2987,6 +2977,12 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel } tempFile = File.createTempFile("temp", ".swf"); tempFile.deleteOnExit(); + + Color backgroundColor = View.swfBackgroundColor; + if (tagObj instanceof FontTag) { //Fonts are always black on white + backgroundColor = View.DEFAULT_BACKGROUND_COLOR; + } + try (FileOutputStream fos = new FileOutputStream(tempFile)) { SWFOutputStream sos = new SWFOutputStream(fos, 10); sos.write("FWS".getBytes()); @@ -3008,16 +3004,23 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel int height = swf.displayRect.Ymax - swf.displayRect.Ymin; sos2.writeRECT(swf.displayRect); sos2.writeUI8(0); - sos2.writeUI8(swf.frameRate); + sos2.writeUI8(50);//swf.frameRate); sos2.writeUI16(frameCount); //framecnt - FileAttributesTag fa = new FileAttributesTag(); + /*FileAttributesTag fa = new FileAttributesTag(); sos2.writeTag(fa); - - Color backgroundColor = View.swfBackgroundColor; - if (tagObj instanceof FontTag) { //Fonts are always black on white - backgroundColor = Color.white; - } +*/ + if (tagObj instanceof FrameNode) { + FrameNode fn = (FrameNode) tagObj; + if(fn.getParent() == null){ + for (Tag t : swf.tags) { + if (t instanceof SetBackgroundColorTag) { + backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor(); + break; + } + } + } + } sos2.writeTag(new SetBackgroundColorTag(null, new RGB(backgroundColor))); @@ -3229,7 +3232,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel showCard(CARDFLASHPANEL); if (flashPanel != null) { if (flashPanel instanceof FlashPlayerPanel) { - flashPanel.displaySWF(tempFile.getAbsolutePath()); + flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/View.java b/trunk/src/com/jpexs/decompiler/flash/gui/View.java index 371823a30..2c21a4517 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/View.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/View.java @@ -55,8 +55,9 @@ import org.pushingpixels.substance.api.skin.SubstanceOfficeBlue2007LookAndFeel; */ public class View { - public static Color swfBackgroundColor = Color.white; - + public static final Color DEFAULT_BACKGROUND_COLOR = new Color(217,231,250); + public static Color swfBackgroundColor = DEFAULT_BACKGROUND_COLOR; + /** * Sets windows Look and Feel */ diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index f6f6ef791..64a1bb4d4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -12,6 +12,7 @@ import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser; import com.sun.jna.ptr.IntByReference; +import java.awt.Color; import java.awt.Graphics; import java.awt.Panel; import java.awt.event.ComponentEvent; @@ -38,17 +39,27 @@ public class FlashPlayerPanel extends Panel { private static List pipes = new ArrayList<>(); private JFrame frame; private boolean stopped=false; + + private static final int CMD_PLAY = 1; + private static final int CMD_RESIZE = 2; + private static final int CMD_BGCOLOR = 3; private synchronized void resize() { if (pipe != null) { IntByReference ibr = new IntByReference(); - Kernel32.INSTANCE.WriteFile(pipe, new byte[]{2}, 1, ibr, null); + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{CMD_RESIZE}, 1, ibr, null); Kernel32.INSTANCE.WriteFile(pipe, new byte[]{ (byte) (getWidth() / 256), (byte) (getWidth() % 256), (byte) (getHeight() / 256), (byte) (getHeight() % 256),}, 4, ibr, null); } } + public synchronized void setBackgroundColor(Color color) { + IntByReference ibr = new IntByReference(); + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{CMD_BGCOLOR}, 1, ibr, null); + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{(byte)color.getRed(),(byte)color.getGreen(),(byte)color.getBlue()},3,ibr,null); + } + public FlashPlayerPanel(JFrame frame) { if (!Platform.isWindows()) { throw new FlashUnsupportedException(); @@ -111,16 +122,18 @@ public class FlashPlayerPanel extends Panel { } public synchronized void stopSWF(){ - displaySWF("-"); + displaySWF("-",null); stopped = true; } public synchronized boolean isStopped() { return stopped; } + public synchronized void displaySWF(String flash){ + displaySWF(flash, Color.white); + } - - public synchronized void displaySWF(String flash) { + public synchronized void displaySWF(String flash,Color bgColor) { this.flash = flash; repaint(); if (!executed) { @@ -130,10 +143,13 @@ public class FlashPlayerPanel extends Panel { } catch (InterruptedException ex) { Logger.getLogger(FlashPlayerPanel.class.getName()).log(Level.SEVERE, null, ex); } + } + if(bgColor!=null){ + setBackgroundColor(bgColor); } if (pipe != null) { IntByReference ibr = new IntByReference(); - Kernel32.INSTANCE.WriteFile(pipe, new byte[]{1}, 1, ibr, null); + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{CMD_PLAY}, 1, ibr, null); Kernel32.INSTANCE.WriteFile(pipe, new byte[]{(byte) flash.getBytes().length}, 1, ibr, null); Kernel32.INSTANCE.WriteFile(pipe, flash.getBytes(), flash.getBytes().length, ibr, null); }