Sign in Join

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

Mailing lists / lazarus / 2013-05

TFPImageCanvas and TFreeTypeFont colors

11 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Leonardo M. Ramé

Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I noted some times, the text contains wrong colors around the pixels of the text.

I've attached an image to show the problem. As you can see, the text over light gray and white is adding red dots, that doesn't have to be there.

The resulting image is an TFPMemoryImage composed of two TFPImageCanvas one containing the image and a 2nd one containing the text.

How can I avoid those red dots?.

Regards,

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- A non-text attachment was scrubbed... Name: freetypefont.png Type: image/png Size: 14131 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130510/6031fe06/attachment-0001.png>

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 12 lines
Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I noted some times, the text contains wrong colors around the pixels of the text. I've attached an image to show the problem. As you can see, the text over light gray and white is adding red dots, that doesn't have to be there. The resulting image is an TFPMemoryImage composed of two TFPImageCanvas one containing the image and a 2nd one containing the text. How can I avoid those red dots?.

Are you using antialiasing ?
If so, try switching it off.

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt
Michael Van Canneyt wrote 20 lines
On Fri, 10 May 2013, Leonardo M. Ram? wrote: >Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I >noted some times, the text contains wrong colors around the pixels of >the text. > >I've attached an image to show the problem. As you can see, the text >over light gray and white is adding red dots, that doesn't have to be >there. > >The resulting image is an TFPMemoryImage composed of two TFPImageCanvas >one containing the image and a 2nd one containing the text. > >How can I avoid those red dots?. Are you using antialiasing ? If so, try switching it off.

Thanks, after setting AntiAliased to false, the red dots where removed, but fonts look really ugly (like shrinked or something). Please take a look at the attached image, the font is Arial 10.

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- A non-text attachment was scrubbed... Name: Captura de pantalla - 100513 - 15:37:49.png Type: image/png Size: 9373 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130510/a50616db/attachment.png>

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 25 lines
On 2013-05-10 20:34:00 +0200, Michael Van Canneyt wrote: > > > On Fri, 10 May 2013, Leonardo M. Ram? wrote: > >> Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I >> noted some times, the text contains wrong colors around the pixels of >> the text. >> >> I've attached an image to show the problem. As you can see, the text >> over light gray and white is adding red dots, that doesn't have to be >> there. >> >> The resulting image is an TFPMemoryImage composed of two TFPImageCanvas >> one containing the image and a 2nd one containing the text. >> >> How can I avoid those red dots?. > > Are you using antialiasing ? > If so, try switching it off. > Thanks, after setting AntiAliased to false, the red dots where removed, but fonts look really ugly (like shrinked or something). Please take a look at the attached image, the font is Arial 10.

Strange. Did you rescale any of the images ?

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt
Michael Van Canneyt wrote 32 lines
On Fri, 10 May 2013, Leonardo M. Ram? wrote: >On 2013-05-10 20:34:00 +0200, Michael Van Canneyt wrote: >> >> >>On Fri, 10 May 2013, Leonardo M. Ram? wrote: >> >>>Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I >>>noted some times, the text contains wrong colors around the pixels of >>>the text. >>> >>>I've attached an image to show the problem. As you can see, the text >>>over light gray and white is adding red dots, that doesn't have to be >>>there. >>> >>>The resulting image is an TFPMemoryImage composed of two TFPImageCanvas >>>one containing the image and a 2nd one containing the text. >>> >>>How can I avoid those red dots?. >> >>Are you using antialiasing ? >>If so, try switching it off. >> > >Thanks, after setting AntiAliased to false, the red dots where removed, >but fonts look really ugly (like shrinked or something). Please take a >look at the attached image, the font is Arial 10. Strange. Did you rescale any of the images ?

No. I've also tested writing the image to a bmp file, but the result is the same.

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 36 lines
On 2013-05-10 21:00:37 +0200, Michael Van Canneyt wrote: > > > On Fri, 10 May 2013, Leonardo M. Ram? wrote: > >> On 2013-05-10 20:34:00 +0200, Michael Van Canneyt wrote: >>> >>> >>> On Fri, 10 May 2013, Leonardo M. Ram? wrote: >>> >>>> Hi, I'm writing text over TFPImageCanvas using a TFreeTypeFont, and I >>>> noted some times, the text contains wrong colors around the pixels of >>>> the text. >>>> >>>> I've attached an image to show the problem. As you can see, the text >>>> over light gray and white is adding red dots, that doesn't have to be >>>> there. >>>> >>>> The resulting image is an TFPMemoryImage composed of two TFPImageCanvas >>>> one containing the image and a 2nd one containing the text. >>>> >>>> How can I avoid those red dots?. >>> >>> Are you using antialiasing ? >>> If so, try switching it off. >>> >> >> Thanks, after setting AntiAliased to false, the red dots where removed, >> but fonts look really ugly (like shrinked or something). Please take a >> look at the attached image, the font is Arial 10. > > Strange. Did you rescale any of the images ? > No. I've also tested writing the image to a bmp file, but the result is the same.

Can you produce a bitmap with just the text and see what that looks like ?

Michael.

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 6 lines
On 2013-05-10 21:29:48 +0200, Michael Van Canneyt wrote: > > Can you produce a bitmap with just the text and see what that looks like ? > I've tried that, and the result is the same.

Well.
Normally TFPImage does not perform any transformation on the bitmaps that the freetype engine produces: it just copies the result to the bitmap it is treating. So if that bitmap is empty, you get what FreeType produced.

So this is rather strange to hear. Unfortunately, I do not know what to advise, except debugging :(

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt
Michael Van Canneyt wrote 18 lines
On Fri, 10 May 2013, Leonardo M. Ram? wrote: >On 2013-05-10 21:29:48 +0200, Michael Van Canneyt wrote: >> >>Can you produce a bitmap with just the text and see what that looks like ? >> > >I've tried that, and the result is the same. Well. Normally TFPImage does not perform any transformation on the bitmaps that the freetype engine produces: it just copies the result to the bitmap it is treating. So if that bitmap is empty, you get what FreeType produced. So this is rather strange to hear. Unfortunately, I do not know what to advise, except debugging :(

Well, maybe this can help. The background image is created from an RGBA 8bit pixel array, assigned to a TFPMemoryImage this way:

FCanvasImage.Colors[lXPos, lYPos] :=
FPColor(
lBlue shl 8 + lBlue,
lGreen shl 8 + lGreen,
lRed shl 8 + lRed,

    $ff shl 8 + $ff);

lRed, lGreen and lBlue are of type byte, while FPColor needs word, that's why I have to do the calcs. Maybe the calcs are wrong.

Regards,

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 32 lines
On 2013-05-10 21:53:21 +0200, Michael Van Canneyt wrote: > > > On Fri, 10 May 2013, Leonardo M. Ram? wrote: > >> On 2013-05-10 21:29:48 +0200, Michael Van Canneyt wrote: >>> >>> Can you produce a bitmap with just the text and see what that looks like ? >>> >> >> I've tried that, and the result is the same. > > Well. Normally TFPImage does not perform any transformation on the > bitmaps that the freetype engine produces: it just copies the result > to the bitmap it is treating. So if that bitmap is empty, you get > what FreeType produced. > > So this is rather strange to hear. Unfortunately, I do not know what to advise, except debugging :( > Well, maybe this can help. The background image is created from an RGBA 8bit pixel array, assigned to a TFPMemoryImage this way: FCanvasImage.Colors[lXPos, lYPos] := FPColor( lBlue shl 8 + lBlue, lGreen shl 8 + lGreen, lRed shl 8 + lRed, $ff shl 8 + $ff); lRed, lGreen and lBlue are of type byte, while FPColor needs word, that's why I have to do the calcs. Maybe the calcs are wrong.

They seem correct.

I don't think that the overlaying is wrong. I tend to think that the bitmap you get from freetype is somehow wrong...

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt
Michael Van Canneyt wrote 42 lines
On Fri, 10 May 2013, Leonardo M. Ram? wrote: >On 2013-05-10 21:53:21 +0200, Michael Van Canneyt wrote: >> >> >>On Fri, 10 May 2013, Leonardo M. Ram? wrote: >> >>>On 2013-05-10 21:29:48 +0200, Michael Van Canneyt wrote: >>>> >>>>Can you produce a bitmap with just the text and see what that looks like ? >>>> >>> >>>I've tried that, and the result is the same. >> >>Well. Normally TFPImage does not perform any transformation on the >>bitmaps that the freetype engine produces: it just copies the result >>to the bitmap it is treating. So if that bitmap is empty, you get >>what FreeType produced. >> >>So this is rather strange to hear. Unfortunately, I do not know what to advise, except debugging :( >> > >Well, maybe this can help. The background image is created from an RGBA >8bit pixel array, assigned to a TFPMemoryImage this way: > >FCanvasImage.Colors[lXPos, lYPos] := > FPColor( > lBlue shl 8 + lBlue, > lGreen shl 8 + lGreen, > lRed shl 8 + lRed, > $ff shl 8 + $ff); > >lRed, lGreen and lBlue are of type byte, while FPColor needs word, >that's why I have to do the calcs. Maybe the calcs are wrong. They seem correct. I don't think that the overlaying is wrong. I tend to think that the bitmap you get from freetype is somehow wrong...

Hopefully someone find a fix to it...

Reply by email