View Issue Details

IDProjectCategoryView StatusLast Update
0035128FPCFCLpublic2019-11-15 18:11
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0035128: fcl-image Clipping bug: SortRect in CheckRectClipping results in wrong exceptions
Descriptionthe 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 Reproduceprogram 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.
TagsNo tags attached.
Fixed in Revision43479
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Michael Van Canneyt

2019-11-15 16:18

administrator   ~0119321

It was not just CheckRectClipping. Fixed.

Ondrej Pokorny

2019-11-15 18:11

developer   ~0119326

Thank you!

Issue History

Date Modified Username Field Change
2019-02-21 10:46 Ondrej Pokorny New Issue
2019-02-21 15:02 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-02-21 15:02 Michael Van Canneyt Status new => assigned
2019-11-15 16:18 Michael Van Canneyt Status assigned => resolved
2019-11-15 16:18 Michael Van Canneyt Resolution open => fixed
2019-11-15 16:18 Michael Van Canneyt Fixed in Version => 3.3.1
2019-11-15 16:18 Michael Van Canneyt Fixed in Revision => 43479
2019-11-15 16:18 Michael Van Canneyt FPCTarget => 3.2.0
2019-11-15 16:18 Michael Van Canneyt Note Added: 0119321
2019-11-15 18:11 Ondrej Pokorny Status resolved => closed
2019-11-15 18:11 Ondrej Pokorny Note Added: 0119326