The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hila123 on June 23, 2005, 07:41:14 AM

Title: how can i generate a bitmap image consist of a string?
Post by: hila123 on June 23, 2005, 07:41:14 AM
hi, i'm new to win32 assembly,

here is my problem

how can i generate a bitmap consist of a string....
for example,
i have a string "i love assembly", how can i generate a bitmap image consist of the string?
Title: Re: how can i generate a bitmap image consist of a string?
Post by: Tedd on June 23, 2005, 10:54:20 AM
You create the bitmap in memory, and draw the string onto the bitmap, and then you can save it to a file (or do whatever you want.)

Next question: how do I do that? :bg
Title: Re: how can i generate a bitmap image consist of a string?
Post by: donkey on June 23, 2005, 12:12:01 PM
You can create the bitmap and then draw the string directly to it. It will go something like this, I just typed this without testing it so it might need a bit of tweaking...

invoke GetDC, [hWinMain]
mov [hdc], eax

invoke CreateCompatibleBitmap, [hdc], 500, 500
mov [hBmp], eax

invoke CreateCompatibleDC, [hdc]
mov [memDC], eax

invoke ReleaseDC, [hdc]

mov D[rect.top], 0
mov D[rect.bottom], 0
mov D[rect.left], 500
mov D[rect.right], 500

invoke DrawText, [memDC], "Hello",1,offset rect,DT_CENTER + DT_VCENTER

invoke DeleteDC, [memDC]