Board index » delphi » Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??

Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??

I use WinAPI function DrawText to render some text.
DrawText requires a HDC - handle to a devicecontext.
However, I would like to render the text in memory, so I would like to use a TBitmap.Canvas.Handle
instead. Is that safe?
--
Yours

Poul Bak
(Remove NOSPAM from my e-mail address to answer directly)

Life is too short to reinvent the wheel just because you don't like the color - use a hub cap and
get on with your life!

 

Re:Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??


Quote
"Poul Bak" <NOSPAMpoul.s....@get2net.dk> wrote in message

news:3ab4f63b_2@dnews...

Quote
> However, I would like to render the text in memory, so I would like to use

a TBitmap.Canvas.Handle

Quote
> instead. Is that safe?

Yes, but beware of video driver problems. Unless I turn hardware
acceleration off, rendering text past a certain size (about 40-44 pixels
depending on the font) tends to corrupt the canvas. I'm using a Matrox MGA
G-200 AGP with V4.10.01.4240 drivers which, so far, is the only hardware
I've seen exhibiting this kind of behaviour.

G. Stewart.

Re:Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??


"Godwin Stewart" <nospamplease.ponti...@bigfoot.com> skrev i en meddelelse news:3ab52039_1@dnews...

Quote
> "Poul Bak" <NOSPAMpoul.s....@get2net.dk> wrote in message
> news:3ab4f63b_2@dnews...

> > However, I would like to render the text in memory, so I would like to use
> a TBitmap.Canvas.Handle
> > instead. Is that safe?

> Yes, but beware of video driver problems. Unless I turn hardware
> acceleration off, rendering text past a certain size (about 40-44 pixels
> depending on the font) tends to corrupt the canvas. I'm using a Matrox MGA
> G-200 AGP with V4.10.01.4240 drivers which, so far, is the only hardware
> I've seen exhibiting this kind of behaviour.

> G. Stewart.

When I render the text in a memory bitmap then there's no difference between text and other graphics
(when I finally draw the bitmap on the screen). So that problem should also be eliminated, right?

--
Yours

Poul Bak
(Remove NOSPAM from my e-mail address to answer directly)

Life is too short to reinvent the wheel just because you don't like the color - use a hub cap and
get on with your life!

- Show quoted text -

Quote

Re:Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??


Quote
"Poul Bak" <NOSPAMpoul.s....@get2net.dk> wrote in message

news:3ab5be63_1@dnews...

Quote
> When I render the text in a memory bitmap then there's no difference

between text and other graphics
Quote
> (when I finally draw the bitmap on the screen). So that problem should

also be eliminated, right?

In theory, yes. But then again, it shouldn't arise in the first place - in
theory...

I never saw the problem with my ancient S3 VirgeDX and Trio-64V PCI boards,
nor with the SiS AGP board on the other machine here. The Matrox messing
things up really caught me unawares but I think it's a *very* uncommon
problem.

A few field trials of your software on various systems might be a good idea.
Also, If you'd like to post the part of your code doing the in-memory
rendering, I can probably try it out on the Matrox.

GRS

Other Threads