flat assembler
Message board for the users of flat assembler.

Index > Windows > Fasm load image file into memory and display it (png or jpg)

Author
Thread Post new topic Reply to topic
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog
Hi everybody.
I found some code from vortex(thanks) on the forum that loads bmp file into memeory so you can display it. I was wondering how can I change it so it can load a png or a jpg
here is the meat of the code

Code:
 invoke  GetClientRect,[hwnd],client
        lea     eax,[pBitmap+14] ; start of BITMAPINFOHEADER header
        invoke  CreateDIBSection,0,eax,DIB_RGB_COLORS,ppvBits,0,0
        mov     [hBitmap],eax
        lea     eax,[pBitmap+54] ; + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
        stdcall MemCopy,eax,[ppvBits],149346-54 ; copy bitmap's bit values  
    

it looks like the file header is 54 bytes or 14 bytes so how would I change it to work with a png or jpg? I read that png is 8 bytes so I changed all the numbers to 8 and it did not work. It is probably an easy fix but I am not that great at assembly yet.

thanks so much!
Post 16 Apr 2014, 22:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
PNG is a compressed format. You will need to change more than just the header length, you also need to decompress the data.

Windows has a COM class for image display. Look up IPictureList.
Post 17 Apr 2014, 01:01
View user's profile Send private message Visit poster's website Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 143
Walter
Post 17 Apr 2014, 02:52
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.