flat assembler
Message board for the users of flat assembler.
Index
> Windows > Bitmap & .bmp |
Author |
|
tantrikwizard 17 Feb 2007, 18:31
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 ? |
|||
17 Feb 2007, 18:31 |
|
maestro-ant 17 Feb 2007, 18:40
it shoud be done like programme.
|
|||
17 Feb 2007, 18:40 |
|
Vasilev Vjacheslav 17 Feb 2007, 18:45
i know how to do it
|
|||
17 Feb 2007, 18:45 |
|
Reverend 18 Feb 2007, 14:05
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 |
|||
18 Feb 2007, 14:05 |
|
maestro-ant 19 Feb 2007, 15:06
But how could we save Bitmap in the file bmp?
|
|||
19 Feb 2007, 15:06 |
|
Reverend 19 Feb 2007, 21:06
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 |
|||
19 Feb 2007, 21:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.