flat assembler
Message board for the users of flat assembler.

Index > Windows > GDI+ PNG Problem

Author
Thread Post new topic Reply to topic
Havok



Joined: 29 Oct 2011
Posts: 7
Havok 25 Nov 2011, 09:33
Hello everyone,

I hope you all had a wonderful Thanksgiving! Smile

I am having some trouble with using GDI+. Searching around the forum I found Thomasz's example of making a JPEG file (thanks so much for it) but just changing "image/jpeg" and the file extension to PNG doesn't work.

I've had no trouble doing this in C++ but here it's giving me some trouble. Here is the code I am working with:
Code:
invoke GdiplusStartup,a,b,0
invoke GdipGetImageEncodersSize,c,d
invoke VirtualAlloc,0,[d],MEM_COMMIT,PAGE_READWRITE
mov ebx,eax
invoke GdipGetImageEncoders,[c],[d],ebx
mov esi,[ebx+ImageCodecInfo.MimeType]
mov edi,e
mov ecx,11
repe cmpsw
add ebx,sizeof.ImageCodecInfo
dec [c]
lea esi,[ebx+ImageCodecInfo.Clsid]
mov edi,f
mov ecx,4
rep movsd
invoke VirtualFree,ebx,0,MEM_RELEASE
invoke GetDC,HWND_DESKTOP
mov esi,eax
invoke GetSystemMetrics,SM_CYSCREEN
mov [g],eax
invoke GetSystemMetrics,SM_CXSCREEN
mov [h],eax
invoke CreateCompatibleBitmap,esi,[h],[g]
mov ebx,eax
invoke CreateCompatibleDC,esi
mov edi,eax
invoke SelectObject,edi,ebx
invoke BitBlt,edi,0,0,[h],[g],esi,0,0,SRCCOPY
invoke GdipCreateBitmapFromHBITMAP,ebx,0,i
invoke GdipSaveImageToFile,[i],j,f,0
invoke GdipDisposeImage,[i]
invoke GdiplusShutdown,[a]
ret

a dd 0
b GdiplusStartupInput 1
c dd 0
d dd 0
e du 'image/png',0
f db 16 dup 0
g dd 0
h dd 0
i dd 0
j du 'test.png',0
    

Any help on how to use this for PNG files would be appreciated.
Post 25 Nov 2011, 09:33
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 25 Nov 2011, 10:30
if you can reverse engineer this screen grabber then your troubles will be over.

http://gyazo.com/en
Post 25 Nov 2011, 10:30
View user's profile Send private message Reply with quote
wolf



Joined: 28 Sep 2003
Posts: 11
wolf 06 Feb 2013, 16:59
change the line

'mov ecx,11' into 'mov ecx,10'

or mov ecx,strlen(e) = 10 or 11

works for bmp / jpeg / tiff / gif / png
Post 06 Feb 2013, 16:59
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.