瀏覽代碼

avoid size overflow

johann 5 年之前
父節點
當前提交
8c7df37697
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      lazpaint/uimagepreview.pas

+ 4 - 3
lazpaint/uimagepreview.pas

@@ -100,7 +100,7 @@ type
 implementation
 
 uses FPimage, BGRAReadJpeg, BGRAOpenRaster, BGRAPaintNet, BGRAReadLzp, Dialogs, UNewimage,
-  LCLType, BGRAPhoxo, BGRASVG, math, URaw;
+  LCLType, BGRAPhoxo, BGRASVG, math, URaw, UImage;
 
 { TImagePreview }
 
@@ -933,8 +933,9 @@ begin
       ifSvg:
         begin
           svg := TBGRASVG.Create(source);
-          FSingleImage := TBGRABitmap.Create(ceil(svg.WidthAsPixel),ceil(svg.HeightAsPixel));
-          svg.Draw(FSingleImage.Canvas2d,0,0);
+          with ComputeAcceptableImageSize(ceil(svg.WidthAsPixel),ceil(svg.HeightAsPixel)) do
+            FSingleImage := TBGRABitmap.Create(cx,cy);
+          svg.StretchDraw(FSingleImage.Canvas2d,0,0,FSingleImage.Width,FSingleImage.Height);
           svg.Free;
           FImageNbLayers:= 1;
         end