[fpc-devel] Is this a bug? TFPImageCanvas.StretchDraw

Martin fpc at mfriebe.de
Wed Jul 11 13:17:36 CEST 2018


I am investigating this, because similar artefacts can be seen in the 
new PPI related stretched images in Lazarus.

Add below code to a form with 2 TImages on it. (on windows / fpc 3.1.1 
39275)

It stretches the image to 3 times it size.



The magnified result (bottom part)


1) For a single pixel line (left) of a solid color, I would expect a 3 
pixel wide line without anti aliasing. Though yes, the anti aliasing 
could be ok...

2) But  if there is anti aliasing, and even if the anti aliasing goes 
over 3 pixels, aren't the shades just in reverse order.
   Shouldn't the darkest be farest from the red, not closest?

3) Similar the dark red part of the right line (The right line is 1px 
bright and 1px dark red before stretch).
Aren't the shades in the wrong order? (there are 3 shades of dark red, 
on the right side of the bright red, starting with the darkest.)




procedure TForm1.FormCreate(Sender: TObject);
var
   ScFI, ScFI2: TFPCompactImgRGBA8Bit;
   ScCanvas: TFPImageCanvas;
   i, x, y: Integer;
   c : TFPColor;
begin
   ScFI := TFPCompactImgRGBA8Bit.Create(30, 30);

   for x := 0 to 29 do for y := 0 to 29 do begin
     c.alpha := $FFFF;
     c.green := 0;
     c.blue := 0;
     c.Red := 0;
     ScFI.Colors[x,y] := c;
   end;

   for i := 1 to 20 do begin
     c.alpha := $FFFF;
     c.green := 0;
     c.blue := 0;
     c.Red := $FFFF;
     ScFI.Colors[10,i] := c;
     ScFI.Colors[20,i] := c;
     //c.blue := 10;
     c.Red := $7F7F;
     ScFI.Colors[21,i] := c;
   end;

   for x := 0 to 29 do for y := 0 to 29 do
     Image1.Canvas.Pixels[x,y] :=
       Byte(ScFI.Colors[x,y].red) +
       Byte(ScFI.Colors[x,y].green) << 8 +
       Byte(ScFI.Colors[x,y].blue) << 16;

   ScFI2 := TFPCompactImgRGBA8Bit.Create(90, 90);
   ScCanvas := TFPImageCanvas.create(ScFI2);
   ScCanvas.StretchDraw(0,0, 90, 90, scFI);

   for x := 0 to 89 do for y := 0 to 89 do
     Image2.Canvas.Pixels[x,y] :=
       Byte(ScCanvas.Colors[x,y].red) +
       Byte(ScCanvas.Colors[x,y].green) << 8 +
       Byte(ScCanvas.Colors[x,y].blue) << 16;
end;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180711/0886cb10/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jppahfgakbnikjhk.png
Type: image/png
Size: 1417 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180711/0886cb10/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ebbfghkdogfbnfoi.png
Type: image/png
Size: 1068 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180711/0886cb10/attachment-0001.png>


More information about the fpc-devel mailing list