[Lazarus] StretchDraw and antialiasing in 0.9.28

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Fri May 21 12:52:01 CEST 2010


Mark Morgan Lloyd wrote:
> I've been looking through the archives without being able to work out 
> the current situation. Is it possible to disable antialiasing when using 
> e.g. TImageList.StretchDraw() in 0.9.28?

I ended up hardcoding something as the best way of getting a guaranteed 
result. Noted that there are various interpolation classes but I had 
difficulty finding examples or documentation, and my requirement is 
sharp not pretty.

However, I had a considerable amount of "fun" moving image data around. 
The "A faster version" example at 
http://wiki.lazarus.freepascal.org/Developing_with_Graphics suggests 
that each pixel is a TRGBTriple, but I found that in my code it was 16 
bits, presumably determined by the .bmp file that Lazarus originally 
read into a TImageList.

Where the amount of storage allocated for the image is smaller than 
SizeOf(TRGBTriple) per pixel, the example as given risks corrupting the 
heap- in the most benign case I was getting an exception during a 
subsequent FreeAndNil().

I'm sure that the correct way to fix this is to refer to the known 
palette types, but as an interim hack I've deduced the amount of storage 
per row using

     TRY
       src:= img.GetDataLineStart(0);
       dst:= img.GetDataLineStart(1);
       bytesPerRow:= LONGINT(dst) - LONGINT(src)
     EXCEPT
       bytesPerRow:= (img.Width + 7) DIV 8 (* Extreme fallback case *)
     END;
..
           Move(src^, dst^, bytesPerRow)

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list