Browse Source

#376 fill background with white for printing

Juliette ELSASS 1 year ago
parent
commit
8678cd0b7a
1 changed files with 8 additions and 2 deletions
  1. 8 2
      lazpaint/dialog/uprint.pas

+ 8 - 2
lazpaint/dialog/uprint.pas

@@ -436,6 +436,7 @@ end;
 procedure TFPrint.Button_PrintClick(Sender: TObject);
 procedure TFPrint.Button_PrintClick(Sender: TObject);
 var FPrintTransform: TAffineMatrix;
 var FPrintTransform: TAffineMatrix;
   marTopLeft,marBottomRight,imgTopLeft,imgBottomRight: TPointF;
   marTopLeft,marBottomRight,imgTopLeft,imgBottomRight: TPointF;
+  bmp: TBitmap;
   area: TRect;
   area: TRect;
 begin
 begin
   if (unrotatedTotalMarginInPoints.x >= paperSizeInPoints.x) or
   if (unrotatedTotalMarginInPoints.x >= paperSizeInPoints.x) or
@@ -466,8 +467,13 @@ begin
       Printer.Canvas.Clipping := true;
       Printer.Canvas.Clipping := true;
       imgTopLeft := FPrintTransform*FImagePos;
       imgTopLeft := FPrintTransform*FImagePos;
       imgBottomRight := FPrintTransform*(FImagePos+FImageSize);
       imgBottomRight := FPrintTransform*(FImagePos+FImageSize);
-      Printer.Canvas.StretchDraw(rect(round(imgTopLeft.x),round(imgTopLeft.y),
-        round(imgBottomRight.x),round(imgBottomRight.y)), Instance.Image.RenderedImage.Bitmap);
+      bmp := Instance.Image.RenderedImage.MakeBitmapCopy(clWhite);
+      try
+        Printer.Canvas.StretchDraw(rect(round(imgTopLeft.x),round(imgTopLeft.y),
+          round(imgBottomRight.x),round(imgBottomRight.y)), bmp);
+      finally
+        bmp.Free;
+      end;
       Printer.Canvas.Clipping := false;
       Printer.Canvas.Clipping := false;
     end;
     end;
     Printer.EndDoc;
     Printer.EndDoc;