Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-07

Is this a bug? TFPImageCanvas.StretchDraw

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

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;

Reply by email

Martin
to Martin

Btw, a 2nd issue.

If you put the dark read pixels on the right most edge of the image (reduce width to 22), then it is missing in the stretched image.

  ScFI := TFPCompactImgRGBA8Bit.Create(22, 30);

...

Show quoted text 5 lines
ScFI.Colors[20,i] := c;     //c.blue := 10;     c.Red := $7F7F;     ScFI.Colors[21,i] := c;   end;

Reply by email