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?
Mailing lists / lazarus / 2010-05
StretchDraw and antialiasing in 0.9.28
17 messages · 6 people · –
- MMark Morgan Lloyd 7
- GGraeme Geldenhuys 3
- FFelipe Monteiro de Carvalho 2
- MMichael Schnell 2
- PPaul Ishenin 2
- RRazvan Adrian Bogdan 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
On Tue, May 11, 2010 at 3:17 AM, Mark Morgan Lloyd <
Show quoted text 6 lines
Last time i checked this was dependent on the widgetset being used, in GTK filtering was enabled but in GDI(Win32) it was not.
Razvan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100511/07dd968e/attachment.html>
I've been looking through the archives without being able to work out the current…
Mark Morgan Lloyd wroteI'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?
You have to select it in the canvas.
See TCanvas.AntiAliasingMode (or something similar)
Felipe Monteiro de Carvalho wrote 7 lines
Thanks Felipe, I've already got
aCanvas.AntialiasingMode:= amOff;
Hp495xDisplayForm.SignalBitmaps.StretchDraw(aCanvas, index, aRect);(where aCanvas refers to a visible DrawGrid) but it's still coming out blurred.
In which operating system / widgetset?
Felipe Monteiro de Carvalho wroteIn which operating system / widgetset?
Linux/i386 (Debian "Lenny") with both gtk1 and 2. If you want detailed library versions please remind me of the command to use.
As an aside, is there an easy way for a program to query widget set version for an About box? Obviously conditional compilation can be used for a gross check but not to get a detailed version.
On Tue, May 11, 2010 at 12:17 PM, Mark Morgan Lloyd You have to select it in the canvas.…
Felipe Monteiro de Carvalho wroteYou have to select it in the canvas. See TCanvas.AntiAliasingMode (or something similar)
Implemented for qt and carbon only.
Best regards,
Paul Ishenin.
Paul Ishenin wrote 7 lines
So at least I know what's going on now :-)
I can live without it (or stretch in my own code) but are there any plans to get it into other widget sets, or a gtk workaround?
Mark Morgan Lloyd wrote 5 lines
Gtk gives no option at moment to disable antialiasing.
Best regards,
Paul Ishenin.
Paul Ishenin wrote 8 lines
Thanks Paul, noted.
Mark Morgan Lloyd wrote> > Gtk gives no option at moment to disable antialiasing. Thanks Paul, noted.
Can't you use one of the Interpolation classes defined in FPCanvas? There are already something like 7-10 different ones to choose from. Maybe create a new Interpolation class that simulates non-antialiasing if one doesn't already exist?
Units in fcl-image:
fpcanvas.pp
extinterpolation.pp
Just a thought.
Graeme Geldenhuys wrote 11 lines
And a very interesting thought :-) Do you have (a reference to) any examples?
The really important thing in the current case is sharpness: I'm enlarging a bitmap that might contain two hex characters fitted into 8x14 to make them bigger rather than prettier, so residual blockiness isn't too much of a problem.
Mark Morgan Lloyd wroteAnd a very interesting thought :-) Do you have (a reference to) any examples?
Sorry, I don't. I only tried out the various interpolation classes when I added Canvas.StretchDraw support into fpGUI long ago.
bitmap that might contain two hex characters fitted into 8x14 to make them bigger rather than prettier, so residual blockiness isn't too much of a
Maybe Felipe's Magnifier application can be of help - I don't know how Felipe enlarges a part of the screen, but maybe that algorithm could be coded as an interpolation class. Otherwise try Google. I have seem some magnifier-type apps that simply enlarge without adding anti-aliasing.
Graeme Geldenhuys wrotebut maybe that algorithm could be coded as an interpolation class.
A well know quite versatile resizing Algorithm is Lanczos (http://en.wikipedia.org/wiki/Lanczos_algorithm). I suppose you can find a lot implementations of same in source code.
-Michael
Michael Schnell wrote> A well know quite versatile resizing Algorithm is Lanczos (http://en.wikipedia.org/wiki/Lanczos_algorithm). I suppose you can find a lot implementations of same in source code.
Lanczos is already implemented in the extinterpolation.pp unit. Class is named TLanczosInterpolation (line 69).
Graeme Geldenhuys wroteLanczos is already implemented in the extinterpolation.pp unit. Classis named TLanczosInterpolation (line 69).
Together with several others. GREAT !!
-Michael
I've been looking through the archives without being able to work out the current…
Mark Morgan Lloyd wroteI'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)