flat assembler
Message board for the users of flat assembler.

Index > Windows > Bitmap & .bmp

Author
Thread Post new topic Reply to topic
maestro-ant



Joined: 20 Aug 2006
Posts: 5
maestro-ant
The file-picture .bmp with the written text in it shoud be created. I think, it's better to create Bitmap and to write the text in it and to save it in a file Is anybody knows how to do it ?

_________________
ICQ 978157
Post 17 Feb 2007, 17:43
View user's profile Send private message ICQ Number Reply with quote
tantrikwizard



Joined: 13 Dec 2006
Posts: 142
tantrikwizard
maestro-ant wrote:
The file-picture .bmp with the written text in it shoud be created. I think, it's better to create Bitmap and to write the text in it and to save it in a file Is anybody knows how to do it ?
Open paint brush, click on the text tool and type in your text. Click file->save as...save it as a bitmap
Post 17 Feb 2007, 18:31
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
maestro-ant



Joined: 20 Aug 2006
Posts: 5
maestro-ant
it shoud be done like programme.
Post 17 Feb 2007, 18:40
View user's profile Send private message ICQ Number Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
i know how to do it
Post 17 Feb 2007, 18:45
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
  • CreateCompatibleDC
  • Create a font (CreateFont or CreateFontIndirectA -> SelectObject)
  • Create a bitmap (CreateBitmap -> SelectObject)
  • SetTextColor, SetBkColor
  • ExtTextOut
  • BitBlt

You'll find all the info in MSDN.
Remeber that ExtTextOut doesn't recognize CR or LF (newline), so you must calculate position for every line and each time call ExtTextOut again.
Below I paste my old code (in masm). It created bitmap with .NFO file content.
Code:
PrepareNfo proc uses ebx edi esi
LOCAL  dwLineCount :DWORD
LOCAL  hBitmap     :DWORD
LOCAL  hFontNfo    :DWORD
LOCAL  dwNfoSize   :DWORD
LOCAL  hBr         :DWORD

       invoke FindResource,hInstance,INFO,RT_RCDATA
       mov    ebx,eax
       invoke LoadResource,hInstance,eax
       mov    hInfoRes,eax
       mov    edi,eax
       invoke SizeofResource,hInstance,ebx
       mov    ecx,eax
       mov    dwNfoSize,eax

       or     esi,-1
       mov    al,13
@@:    inc    esi
       repnz  scasb
       jz     @B
       mov    dwLineCount,esi

       mov    ebx,offset strFont
       assume ebx:ptr LOGFONT
       lea    edi,[ebx].lfFaceName
       mov    esi,offset szTerminal
@@:    lodsb
       stosb
       test   al,al
       jnz    @B
       xor    eax,eax
       and    [ebx].lfPitchAndFamily,al
       and    [ebx].lfQuality,al
       and    [ebx].lfClipPrecision,al
       and    [ebx].lfOutPrecision,al
       mov    [ebx].lfCharSet,1
       and    [ebx].lfStrikeOut,al
       and    [ebx].lfUnderline,al
       and    [ebx].lfItalic,al
       mov    [ebx].lfWeight,200h
       and    [ebx].lfOrientation,eax
       and    [ebx].lfEscapement,eax
       mov    [ebx].lfWidth,6
       mov    [ebx].lfHeight,8
       invoke CreateFontIndirect,ebx
       mov    hFontNfo,eax

       mov    ecx,dwLineCount
       lea    ecx,[ecx*8+2]
       invoke CreateBitmap,480,ecx,1,1,0
       mov    hBitmap,eax

       invoke CreateCompatibleDC,0
       mov    hDC,eax

       invoke SelectObject,hDC,hBitmap
       invoke GetStockObject,BLACK_BRUSH
       mov    hBr,eax
       invoke SelectObject,hDC,eax
       invoke SetTextColor,hDC,00FFFFFFh
       invoke SelectObject,hDC,hFontNfo
       invoke SetBkColor,hDC,0
       mov    ecx,dwLineCount
       lea    ecx,[ecx*8+2]
       invoke Rectangle,hDC,480,ecx,0,0

       invoke GlobalAlloc,GPTR,dwNfoSize
       mov    hInfoText,eax
       mov    esi,hInfoRes
       mov    edi,eax
       mov    ecx,dwNfoSize
       push   ecx
       shr    ecx,2
       rep    movsd
       pop    ecx
       and    ecx,3
       rep    movsb

       mov    ecx,dwNfoSize
       mov    edi,hInfoText
       xor    ebx,ebx

@@:    mov    esi,edi
       mov    al,13
       repnz  scasb
       jnz    @F

       push   ecx
       inc    edi
       mov    byte ptr [edi-2],0
       invoke lstrlen,esi
       invoke ExtTextOut,hDC,0,ebx,ETO_OPAQUE,0,esi,eax,0
       pop    ecx
       add    ebx,8
       jmp    @B
       
@@:    invoke DeleteObject,hFontNfo
       invoke DeleteObject,hBr
       invoke GlobalFree,hInfoText
       mov    eax,dwLineCount
       ret
PrepareNfo endp    
Post 18 Feb 2007, 14:05
View user's profile Send private message Visit poster's website Reply with quote
maestro-ant



Joined: 20 Aug 2006
Posts: 5
maestro-ant
But how could we save Bitmap in the file bmp?
Post 19 Feb 2007, 15:06
View user's profile Send private message ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Read about CreateDIBSection. AFAIR you'll have to declare BITMAPINFO structure yourself (it's not in the standard includes).

I am not a GDI guru, so I can't tell you exact solution from now :/. I only know that the code in my previous post creates a bitmap in compatible dc. CreateDIBSection creates a bitmap with normal access to the bitmap structures and image data. You must find a way to link these two information Smile
Post 19 Feb 2007, 21:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.