flat assembler
Message board for the users of flat assembler.

Index > Windows > LoadImage how change BMP data? VirtualProtect not help !

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 08 Aug 2013, 11:58
I create DialogBox and STATIC. Then LoadImage to STATIC
invoke LoadImage,[C1],'tree.bmp',IMAGE_BITMAP,0,0,LR_LOADFROMFILE
mov [BMPdata],eax
Then i want to change bmp data. But if i do:

Quote:

mov eax,[BMPdata]
add eax,200
mov dword [eax],$10101010


My program crashes with no errors.

I try do invoke VirtualProtect,[BMPdata],4000,PAGE_EXECUTE_READWRITE,OldFlag
This not help.
And do invoke VirtualProtect,[BMPdata],4000,PAGE_READWRITE,OldFlag
This not help.


Last edited by Roman on 08 Aug 2013, 12:02; edited 1 time in total
Post 08 Aug 2013, 11:58
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 08 Aug 2013, 12:00
Interestingly ! How it makes Fasm, when we write:
Quote:

section '.rsrc' resource data readable writeable
bitmap pict,'drakon.bmp'


And we can change pict data !
Post 08 Aug 2013, 12:00
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 08 Aug 2013, 17:46
My code not work ! Fill black color but my bmp have white color !
Quote:

invoke BeginPaint,[C1],ps
mov [hdc],eax
! hMemDC = CreateCompatibleDC,[hdc]
;Åñëè þçàåì LoadImage òî íå íàäî íèæíèå ñòðîêè äî (A)
DIB_RGB_COLORS = 0
mov [bmi.bmiHeader.biSize],sizeof.BITMAPINFOHEADER
mov [bmi.bmiHeader.biWidth], 429;
mov [bmi.bmiHeader.biHeight], 260
mov [bmi.bmiHeader.biPlanes], 1
mov [bmi.bmiHeader.biBitCount], 24
mov [bmi.bmiHeader.biClrImportant],0
mov [bmi.bmiHeader.biSizeImage],0
mov [bmi.bmiHeader.biCompression], 0 ;BI_RGB
! NewBMP = CreateDIBSection,[hdc], bmi, DIB_RGB_COLORS, pict2+54,0,0
;===========(A)===========
; invoke SelectObject,[hMemDC],[NewBMP] ;[hBitmap]
invoke GetClientRect,[C1],rect
invoke SelectObject,[hMemDC],[NewBMP]
invoke BitBlt,[hdc],0,0,[rect.right],[rect.bottom],[hMemDC],0,0,SRCCOPY ;
invoke DeleteDC,[hMemDC]
invoke DeleteObject,[NewBMP] ;[hBitmap]
invoke EndPaint,[C1],ps
Post 08 Aug 2013, 17:46
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 08 Aug 2013, 18:34
if you are having trouble with createdibsection, you might want to look at my example at http://board.flatassembler.net/topic.php?t=15003
Post 08 Aug 2013, 18:34
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 08 Aug 2013, 21:14
After BitBlt() there should be SelectObject() which will pull NewBMP back for deletion.
Post 08 Aug 2013, 21:14
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 09 Aug 2013, 05:53
Thanks ! I found my mistake.
Post 09 Aug 2013, 05:53
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.