Sign in Join

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

Mailing lists / lazarus / 2010-05

StretchDraw and antialiasing in 0.9.28

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd

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?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Razvan Adrian Bogdan
to Mark Morgan Lloyd

On Tue, May 11, 2010 at 3:17 AM, Mark Morgan Lloyd <

Show quoted text 6 lines
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?

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>

Reply by email

Mark Morgan Lloyd
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 7 lines
> 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? You have to select it in the canvas. See TCanvas.AntiAliasingMode (or something similar)

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.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
In 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.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to Paul Ishenin
Paul Ishenin wrote 7 lines
11.05.2010 22:02, Felipe Monteiro de Carvalho wrote: > You have to select it in the canvas. > > See TCanvas.AntiAliasingMode (or something similar) > Implemented for qt and carbon only.

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 markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Paul Ishenin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 5 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?

Gtk gives no option at moment to disable antialiasing.

Best regards,
Paul Ishenin.

Reply by email

Mark Morgan Lloyd
to Paul Ishenin
Paul Ishenin wrote 8 lines
12.05.2010 16:03, Mark Morgan Lloyd wrote: > 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? > Gtk gives no option at moment to disable antialiasing.

Thanks Paul, noted.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Graeme Geldenhuys
to Mark Morgan Lloyd
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.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Mark Morgan Lloyd
to Graeme Geldenhuys
Graeme Geldenhuys wrote 11 lines
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.

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 markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Graeme Geldenhuys
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
And 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.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Michael Schnell
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).

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Mark Morgan Lloyd
to Mark Morgan Lloyd: I've been looking through the archives without being able to work out the current…
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]

Reply by email