fcl-image Clipping bug: SortRect in CheckRectClipping results in wrong exceptions
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
the procedure CheckRectClipping
does SortRect (x1,y1, x2,y2);
This in combination with TFPCustomCanvas.Draw means you get an exception if you want to draw an image outside the clipping (or bitmap) area. Instead nothing should happen - no exception and no drawing.
Steps to reproduce:
program FPCanvasDraw;
{$mode objfpc}{$H+}
uses
FPImage, FPImgCanv, FPCanvas, FPWriteBMP, Classes, SysUtils, pscanvas;
procedure DrawMe1(const aCanvas: TFPCustomCanvas);
var
xImg: TFPMemoryImage;
begin
xImg := TFPMemoryImage.Create(1,1);
xImg.Colors[0,0] := colRed;
aCanvas.ClipRect := Rect(0, 0, 10, 10);
aCanvas.Clipping := True;
aCanvas.Draw(100, 100, xImg); // exception -> BUG (nothing should be painted
xImg.Free;
end;
procedure DrawMe2(const aCanvas: TFPCustomCanvas);
var
xImg: TFPMemoryImage;
begin
xImg := TFPMemoryImage.Create(10,10);
aCanvas.ClipRect := Rect(0, 0, xImg.Width-1, xImg.Height-1);
aCanvas.Clipping := True;
aCanvas.Draw(-100, -100, xImg); // exception -> BUG (nothing should be painted
xImg.Free;
end;
procedure DrawFPC;
var
xNew: TFPMemoryImage;
xCanvas: TFPImageCanvas;
begin
xNew := nil;
xCanvas := nil;
try
xNew := TFPMemoryImage.Create(5, 5);
xCanvas := TFPImageCanvas.Create(xNew);
xCanvas.Brush.FPColor := colRed;
xCanvas.FillRect(0, 0, xNew.Width, xNew.Height);
DrawMe1(xCanvas);
DrawMe2(xCanvas);
xNew.SaveToFile('fpc.bmp');
finally
xCanvas.Free;
xNew.Free;
end;
end;
begin
DrawFPC;
end.
Mantis conversion info:
- Mantis ID: 35128
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 43479 (#42c97b07)
- Target version: 3.2.0