Recent

Author Topic: Disabling anti-aliasing in Image Canvas,  (Read 530 times)

cov

  • Sr. Member
  • ****
  • Posts: 250
Disabling anti-aliasing in Image Canvas,
« on: January 08, 2026, 05:26:01 pm »
I'm trying to transfer text rendered onto a Tbitmap canvas onto another image canvas, but I cannot get rid of the anti aliasing.

This is the image file created (attached), which is unusable:

Reducing the image.PixelFormat:=pf1bit and specifying Image.Monochrome as True gives me an error message.

Runerror (204), invalid pointer operation in the file dynarr.inc at line 129.

Is there a way to disable text antialiasing?

wp

  • Hero Member
  • *****
  • Posts: 13336
Re: Disabling anti-aliasing in Image Canvas,
« Reply #1 on: January 09, 2026, 06:13:40 pm »
You mean you want to remove the extra anti-aliasing pixels from an existing bitmap? I think that's not possible (at least not easily).

cov

  • Sr. Member
  • ****
  • Posts: 250
Re: Disabling anti-aliasing in Image Canvas,
« Reply #2 on: January 09, 2026, 09:34:00 pm »
No.

The image is just to show the anti aliasing.

Code: Pascal  [Select][+][-]
  1.       bmp:= TBitmap.Create;
  2.       bmp.Canvas.TextOut(0,2,'1.789 m³/Hr WATER');        

I want to transfer the image onto the screen pixel by pixel. This is so that I can add additional information related to the text behind each pixel. I hope this makes sense. I'm aware that I could simply Bitblock copy the canvas to the screen, but I'm planning to map each pixel to an array with more information.

The image was simply generated by using bmp.SaveToFile('/tmp/image.bmp') to illustrate what I meant.

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Disabling anti-aliasing in Image Canvas,
« Reply #3 on: January 09, 2026, 11:18:40 pm »
Code: Pascal  [Select][+][-]
  1. bmp.Canvas.Font.quality := fqnonAntialiased
  2.  

jamie

The only true wisdom is knowing you know nothing

cov

  • Sr. Member
  • ****
  • Posts: 250
Re: Disabling anti-aliasing in Image Canvas,
« Reply #4 on: January 10, 2026, 02:05:14 pm »
Thanks.

Unfortunately it doesn't work.

Code: Pascal  [Select][+][-]
  1. bmp.Canvas.Font.Quality:=fqNonAntialiased;
  2. bmp.Canvas.Brush.Style := bsSolid;
  3. bmp.Canvas.Brush.Color := clWhite;
  4. bmp.Canvas.FillRect(0,0,txtWidth,txtHgt);
  5. bmp.Canvas.TextOut(0,2,'1.789 m³/Hr WATER');                              

cov

  • Sr. Member
  • ****
  • Posts: 250
Re: Disabling anti-aliasing in Image Canvas,
« Reply #5 on: January 10, 2026, 05:43:11 pm »
OK, thanks everyone.

According to this, GTK2 does not support fqNonAntialiased.

An alternative work around is suggested.

wp

  • Hero Member
  • *****
  • Posts: 13336
Re: Disabling anti-aliasing in Image Canvas,
« Reply #6 on: January 10, 2026, 06:14:48 pm »
Mentioning nonAntialiased font quality gives the impression that you want to draw text in a non-antialiased way? In this case, simply paint to a monochrome bitmap like in the attached demo project.

 

TinyPortal © 2005-2018