Răsfoiți Sursa

Readme Tweak +Don't allow exceptions from StretchBmp, just return False.

Martijn Laan 7 ani în urmă
părinte
comite
68b36e7385
2 a modificat fișierele cu 55 adăugiri și 52 ștergeri
  1. 51 48
      Components/Resample.pas
  2. 4 4
      README.md

+ 51 - 48
Components/Resample.pas

@@ -148,58 +148,61 @@ const
   NULL = {$IFDEF VER90}nil{$ELSE}0{$ENDIF};
 begin
   Result := False;
-  if (DstWidth <= 0) or (DstHeight <= 0) then Exit;
-  //High quality resampling makes sense only
-  //in True Color and High Color display modes.
-  if GetDeviceCaps(Canvas.Handle, BITSPIXEL) <= 8 then Exit;
-  SrcWidth  := SrcBitmap.Width;
-  SrcHeight := SrcBitmap.Height;
-  if (SrcWidth <= 0) or (SrcHeight <= 0) then Exit;
-  FillChar(BI, SizeOf(BI), 0);
-  BI.bmiHeader.biSize := SizeOf(BI.bmiHeader);
-  BI.bmiHeader.biWidth := SrcWidth;
-  BI.bmiHeader.biHeight := SrcHeight;
-  BI.bmiHeader.biPlanes := 1;
-  BI.bmiHeader.biCompression := BI_RGB;
-  if Is32bit then begin
-    BI.bmiHeader.biBitCount := 32;
-    PixelSize := 4;
-    Proc := PutPixel32P;
-  end else begin
-    BI.bmiHeader.biBitCount := 24;
-    PixelSize := 3;
-    Proc := PutPixel24;
-  end;
-  DstLineSize := (DstWidth * PixelSize + 3) and not 3;
-  SrcLineSize := (SrcWidth * PixelSize + 3) and not 3;
-  GetMem(tmpBits, SrcHeight * DstLineSize);
   try
-    GetMem(SrcBits, SrcLineSize * SrcHeight);
-    try
-      if GetDIBits(Canvas.Handle, SrcBitmap.Handle,
-        0, SrcHeight, SrcBits, BI, DIB_RGB_COLORS) = 0 then Exit;
-      //Stretch horizontally
-      ResampleBits(DstWidth, SrcWidth, SrcBits, tmpBits,
-        PixelSize, SrcHeight, SrcLineSize, DstLineSize, Proc);
-    finally
-      FreeMem(SrcBits);
+    if (DstWidth <= 0) or (DstHeight <= 0) then Exit;
+    //High quality resampling makes sense only
+    //in True Color and High Color display modes.
+    if GetDeviceCaps(Canvas.Handle, BITSPIXEL) <= 8 then Exit;
+    SrcWidth  := SrcBitmap.Width;
+    SrcHeight := SrcBitmap.Height;
+    if (SrcWidth <= 0) or (SrcHeight <= 0) then Exit;
+    FillChar(BI, SizeOf(BI), 0);
+    BI.bmiHeader.biSize := SizeOf(BI.bmiHeader);
+    BI.bmiHeader.biWidth := SrcWidth;
+    BI.bmiHeader.biHeight := SrcHeight;
+    BI.bmiHeader.biPlanes := 1;
+    BI.bmiHeader.biCompression := BI_RGB;
+    if Is32bit then begin
+      BI.bmiHeader.biBitCount := 32;
+      PixelSize := 4;
+      Proc := PutPixel32P;
+    end else begin
+      BI.bmiHeader.biBitCount := 24;
+      PixelSize := 3;
+      Proc := PutPixel24;
     end;
-    BI.bmiHeader.biWidth := DstWidth;
-    BI.bmiHeader.biHeight := DstHeight;
-    DIB := CreateDIBSection(Canvas.Handle, BI, DIB_RGB_COLORS, DstBits, NULL, 0);
-    if DIB = 0 then Exit;
+    DstLineSize := (DstWidth * PixelSize + 3) and not 3;
+    SrcLineSize := (SrcWidth * PixelSize + 3) and not 3;
+    GetMem(tmpBits, SrcHeight * DstLineSize);
     try
-      //Stretch vertically
-      ResampleBits(DstHeight, SrcHeight, tmpBits, DstBits,
-        DstLineSize, DstWidth, PixelSize, PixelSize, Proc);
-      DstBitmap.Handle := DIB;
-      Result := True;
-    except
-      DeleteObject(DIB);
-      raise;
+      GetMem(SrcBits, SrcLineSize * SrcHeight);
+      try
+        if GetDIBits(Canvas.Handle, SrcBitmap.Handle,
+          0, SrcHeight, SrcBits, BI, DIB_RGB_COLORS) = 0 then Exit;
+        //Stretch horizontally
+        ResampleBits(DstWidth, SrcWidth, SrcBits, tmpBits,
+          PixelSize, SrcHeight, SrcLineSize, DstLineSize, Proc);
+      finally
+        FreeMem(SrcBits);
+      end;
+      BI.bmiHeader.biWidth := DstWidth;
+      BI.bmiHeader.biHeight := DstHeight;
+      DIB := CreateDIBSection(Canvas.Handle, BI, DIB_RGB_COLORS, DstBits, NULL, 0);
+      if DIB = 0 then Exit;
+      try
+        //Stretch vertically
+        ResampleBits(DstHeight, SrcHeight, tmpBits, DstBits,
+          DstLineSize, DstWidth, PixelSize, PixelSize, Proc);
+        DstBitmap.Handle := DIB;
+        Result := True;
+      except
+        DeleteObject(DIB);
+        raise;
+      end;
+    finally
+      FreeMem(tmpBits);
     end;
-  finally
-    FreeMem(tmpBits);
+  except
   end;
 end;
 

+ 4 - 4
README.md

@@ -198,10 +198,10 @@ How do the projects link together?
   your installations with the new code, you'll need to copy the new EXE
   file(s) to the Setup Compiler directory under the extension .E32.
 
-- When debugging the Setup project you should set UseSetupLdr=no in your
-  script, and copy the resulting setup-*.bin files to the source code
-  directory. This way you can simulate an actual installation while running
-  under the Delphi debugger.
+- When debugging the Setup project you should set UseSetupLdr=no and
+  OutputBaseFilename=setup in your script, and copy the resulting setup-*.bin
+  files to the source code directory. This way you can simulate an actual
+  installation while runningunder the Delphi debugger.
 
 - All of the forms in the Setup project, with the exception of Main.dfm, have
   Scaled set to False. This is because they dynamically scale themselves at