소스 검색

canvas scale for checkers and shadow, save option background and shadow

Johann ELSASS 4 년 전
부모
커밋
6188f3b70b
2개의 변경된 파일18개의 추가작업 그리고 7개의 파일을 삭제
  1. 14 5
      lazpaint/dialog/usaveoption.pas
  2. 4 2
      lazpaint/uimagepreview.pas

+ 14 - 5
lazpaint/dialog/usaveoption.pas

@@ -179,6 +179,8 @@ begin
   FFlattenedOriginal := nil;
   FSizeCaption:= Label_Size.Caption;
   LayoutRadioButtonDepth;
+  BGRAPreview.BitmapAutoScale:= false;
+  BGRAPreview.Color := clGray;
 end;
 
 procedure TFSaveOption.FormDestroy(Sender: TObject);
@@ -277,7 +279,7 @@ procedure TFSaveOption.BGRAPreviewRedraw(Sender: TObject;
 var ratioX,ratioY,ratio, checkerScale: single;
   picture: TBGRABitmap;
   mustFreePic: boolean;
-  x,y,visualWidth,visualHeight: integer;
+  x,y,visualWidth,visualHeight,ofs: integer;
   r: TRect;
   thumb: TBGRABitmap;
 begin
@@ -333,7 +335,17 @@ begin
   if visualHeight < 1 then visualHeight:= 1;
   x := (Bitmap.Width-visualWidth) div 2;
   y := (Bitmap.Height-visualHeight) div 2;
-  r := rect(x,y,x+visualWidth,y+visualHeight);
+  r := RectWithSize(x, y, visualWidth, visualHeight);
+
+  checkerScale := DoScaleX(60, OriginalDPI)/60;
+  if not BGRAPreview.BitmapAutoScale then
+    checkerScale *= BGRAPreview.GetCanvasScaleFactor;
+  ofs := round(4*checkerScale);
+  if visualWidth < ofs then ofs := visualWidth;
+  if visualHeight < ofs then ofs := visualHeight;
+  bitmap.FillRect(rect(x+visualWidth,y+ofs,x+ofs+visualWidth,y+ofs+visualHeight), BGRA(0,0,0,128),dmDrawWithTransparency);
+  bitmap.FillRect(rect(x+ofs,y+visualHeight,x+visualWidth,y+ofs+visualHeight), BGRA(0,0,0,128),dmDrawWithTransparency);
+
   if ImageFormat in[ifIco,ifCur] then
   begin
     thumb := GetBitmapThumbnail(picture, ImageFormat, visualWidth,visualHeight, BGRAPixelTransparent, true);
@@ -341,9 +353,6 @@ begin
     thumb.Free;
   end else
   begin
-    checkerScale := DoScaleX(60, OriginalDPI)/60;
-    if not BGRAPreview.BitmapAutoScale then
-      checkerScale *= BGRAPreview.GetCanvasScaleFactor;
     DrawCheckers(Bitmap, r, checkerScale);
     Bitmap.StretchPutImage(r, picture, dmDrawWithTransparency);
   end;

+ 4 - 2
lazpaint/uimagepreview.pas

@@ -304,6 +304,7 @@ end;
 procedure TImagePreview.DrawCurrentFrame(Bitmap: TBGRABitmap);
 var x,y,w,h,ofs: integer;
   frame: TBGRABitmap;
+  checkerScale: single;
 begin
   ClearMenu;
   frame := GetCurrentFrameBitmap;
@@ -330,13 +331,14 @@ begin
   end;
   x := (bitmap.Width-w) div 2;
   y := (bitmap.Height-h) div 2;
-  ofs := 4;
+  checkerScale := DoScaleX(round(60*FScaling), OriginalDPI)/60;
+  ofs := round(4*checkerScale);
   if w < ofs then ofs := w;
   if h < ofs then ofs := h;
   bitmap.FillRect(rect(x+w,y+ofs,x+ofs+w,y+ofs+h), BGRA(0,0,0,128),dmDrawWithTransparency);
   bitmap.FillRect(rect(x+ofs,y+h,x+w,y+ofs+h), BGRA(0,0,0,128),dmDrawWithTransparency);
 
-  DrawThumbnailCheckers(Bitmap, rect(x,y,x+w,y+h), false, DoScaleX(round(60*FScaling), OriginalDPI)/60);
+  DrawThumbnailCheckers(Bitmap, rect(x,y,x+w,y+h), false, checkerScale);
   bitmap.StretchPutImage(rect(x,y,x+w,y+h), frame, dmDrawWithTransparency)
 end;