News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hardcode .jpg into .exe

Started by Magnum, May 01, 2010, 02:46:08 AM

Previous topic - Next topic

Magnum

I have code that shows a .jpg, but I would like to have it included in the executable.

I did a search but did not find anything.

I seem to recall there was a way by including the picture in a resource file.

Thanks,
             Andy
Have a great day,
                         Andy

hutch--

Andy,

A couple of ways, either as a binary resource or you can cheat and use a tool in the masm32 directory, FDA or FDA2 that put the data into an object module that you link into your app.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi Magnum,

Here are two examples for you using Ernest Murphy's image loading routines. One of the examples displays a JPG from memory and the other one loads the JPG file to memory.

Hutch's fda ( File Data Assembler ) tool is used to embed the image file into the executable.

jj2007

What about the direct way, using loadimage/getobject?

Vortex

Hi Jochen,

The LoadImage function does not support JPG files.

From Win32.hlp :

QuoteThe LoadImage function loads an icon, cursor, or bitmap.

hutch--

Thomas Bleeker also wrote a JPG library that works fine with JPG files.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php


jj2007

Quote from: Vortex on May 01, 2010, 08:56:12 AM
Hi Jochen,

The LoadImage function does not support JPG files.

From Win32.hlp :

QuoteThe LoadImage function loads an icon, cursor, or bitmap.

Hi Erol,
That's what I thought, too, but I see references in C and Java saying you can... ::)
http://stackoverflow.com/questions/1192054/load-image-from-resources-in-c
http://www.java2s.com/Code/CSharp/Development-Class/Saveandloadimagefromresourcefile.htm

Magnum

Quote from: Vortex on May 01, 2010, 08:26:14 AM
Hi Magnum,

Here are two examples for you using Ernest Murphy's image loading routines. One of the examples displays a JPG from memory and the other one loads the JPG file to memory.

Hutch's fda ( File Data Assembler ) tool is used to embed the image file into the executable.

Thanks to everyone for the help.

I can't find the header files on the board that I need with this.

windows.h commctrl.h and  richedit.h
Have a great day,
                         Andy

hutch--

Probably because they are C/C++ header files. Use the MASM32 WINDOWS.INC.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

joemc

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06
the masm version (as well as the C i believe) uses LoadImage
    invoke LoadImage, hInstance, IDD_BITMAP, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION

edit:
appears the masm only does BMP i need to test it real quick.

joemc

Quote from: jj2007 on May 01, 2010, 09:23:55 AM
That's what I thought, too, but I see references in C and Java saying you can... ::)
http://stackoverflow.com/questions/1192054/load-image-from-resources-in-c
http://www.java2s.com/Code/CSharp/Development-Class/Saveandloadimagefromresourcefile.htm
Those links are both in C#, not C nor Java. and i don't see them calling LoadImage. 

hutch--

joe,

LoadImage is an API that is not MASM specific, anything that can call API functions can call it. There are multiple code sources for MASM that can display a JPG file but Windows in all but the latest version natively displays bitmaps so any other format is converted to BMP.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Hutch,

Joe noted that they don't call LoadImage. I wonder if LoadResource+LockResource would work - as far as I understood, you would get a pointer to the jpg in memory.

hutch--


the masm version (as well as the C i believe) uses LoadImage
    invoke LoadImage, hInstance, IDD_BITMAP, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php