From e6231f2d2e55f7ab8c0797c39eaa64756e61c86a Mon Sep 17 00:00:00 2001 From: Honfika Date: Tue, 24 Dec 2013 15:08:55 +0100 Subject: [PATCH] Issue #428 flash player window resized to the size of the loaded SWF, scalemode is configurable --- trunk/libsrc/Swf2Exe/uMain.pas | 32 ++++++++++++------ .../flash/configuration/Configuration.java | 2 ++ .../com/jpexs/decompiler/flash/gui/Main.java | 11 ++++++ .../com/jpexs/helpers/resource/Swf2Exe.bin | Bin 469504 -> 470016 bytes 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/trunk/libsrc/Swf2Exe/uMain.pas b/trunk/libsrc/Swf2Exe/uMain.pas index 03fd73560..fa5a3537a 100644 --- a/trunk/libsrc/Swf2Exe/uMain.pas +++ b/trunk/libsrc/Swf2Exe/uMain.pas @@ -37,13 +37,16 @@ end; procedure TfrmMain.FormCreate(Sender: TObject); const - exeSize = 469504; + exeSize = 470016; var stream: TFileStream; buffer: array of Byte; tempFile: array[0..MAX_PATH - 1] of Char; tempPath: array[0..MAX_PATH - 1] of Char; flashVarData : TVarData; + width: Integer; + height: Integer; + scaleMode: Byte; begin flaPreview := TMySWF.Create(frmMain); flaPreview.Parent := frmMain; @@ -54,16 +57,25 @@ begin raise Exception.Create( 'GetTempFileName API failed. ' + SysErrorMessage(GetLastError) ); - stream := TFileStream.Create(ParamStr(0), fmOpenRead); - stream.Seek(exeSize, soBeginning); - SetLength(buffer, stream.Size - exeSize); try - stream.Read(buffer[0], Length(buffer)); - finally - stream.Free; + stream := TFileStream.Create(ParamStr(0), fmOpenRead); + stream.Seek(exeSize, soBeginning); + stream.Read(width, 4); + stream.Read(height, 4); + stream.Read(scaleMode, 1); + SetLength(buffer, stream.Size - exeSize); + try + stream.Read(buffer[0], Length(buffer)); + finally + stream.Free; + end; + except + width := 12800; + height := 9600; + scaleMode := 3; end; - stream := TFileStream.Create(ParamStr(0), fmOpenRead); - stream.Seek(exeSize, soBeginning); + ClientWidth := width div 20; + ClientHeight := height div 20; stream := TFileStream.Create(tempFile, fmOpenWrite); try stream.Write(buffer[0], Length(buffer)); @@ -71,7 +83,7 @@ begin stream.Free; end; flaPreview.Movie := tempFile; - flaPreview.ScaleMode := 3; + flaPreview.ScaleMode := scaleMode; end; procedure TfrmMain.FormResize(Sender: TObject); diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 321aa001d..9a6e3b7e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -173,6 +173,8 @@ public class Configuration { public static final ConfigurationItem guiSplitPane1DividerLocation = null; @ConfigurationName("gui.splitPane2.dividerLocation") public static final ConfigurationItem guiSplitPane2DividerLocation = null; + @ConfigurationDefaultInt(3) + public static final ConfigurationItem saveAsExeScaleMode = null; private enum OSId { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 346e0b1c1..581d1eca5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -263,6 +263,17 @@ public class Main { while((bytesRead = exeStream.read(buffer)) != -1) { fos.write(buffer, 0, bytesRead); } + int width = swf.displayRect.Xmax - swf.displayRect.Xmin; + int height = swf.displayRect.Ymax - swf.displayRect.Ymin; + fos.write(width & 0xff); + fos.write((width >> 8) & 0xff); + fos.write((width >> 16) & 0xff); + fos.write((width >> 24) & 0xff); + fos.write(height & 0xff); + fos.write((height >> 8) & 0xff); + fos.write((height >> 16) & 0xff); + fos.write((height >> 24) & 0xff); + fos.write(Configuration.saveAsExeScaleMode.get()); } swf.saveTo(fos); if (tmpFile.exists()) { diff --git a/trunk/src/com/jpexs/helpers/resource/Swf2Exe.bin b/trunk/src/com/jpexs/helpers/resource/Swf2Exe.bin index 7162b05d51b691ab4237738a2e9cd9982613b698..54688ce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