Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Resource and exe (.png)

Author
Message
theplake
16
Years of Service
User Offline
Joined: 30th Nov 2007
Location:
Posted: 27th Dec 2007 13:36
hi

I search a code to show .png pictures from resource.This is for bitmaps:


but how i can this with png pictures?
theplake
16
Years of Service
User Offline
Joined: 30th Nov 2007
Location:
Posted: 27th Dec 2007 15:45
anyone an idea?
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Dec 2007 16:33
change the file name - and experiment - I think it MIGHT do it aw-jo-magically!

theplake
16
Years of Service
User Offline
Joined: 30th Nov 2007
Location:
Posted: 27th Dec 2007 16:42
When i change the filename IDB_BITMAP1 in etc. IDB_PNG1 the png will not be show
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Dec 2007 16:52
Oh - I'm Sorry - I just looked closer at your code after seeing your response. You can't convert gfx formats in memory - only GDK's built in LoadImage (from disk) converts it. It's not the same as a resource.

If you're trying to jam pictures into memory, as part of your EXE, you will need to write your own conversion routines from PNG to the format that MAKE IMAGE FROM MEMBLOCK understands. You might find some open source code along these lines.

Ultimately it looks like you're trying to "hide your media" - and there are a few people on here who have tried that route - with some funky solutions - like random temp directories... but all of them seem to thrash in that they dump data out, then load it back in. I've always thought a Temporary "RAM DRIVE" might be the key here - but I've done nothing to try and figure this out.

I think your easiest solution would be a form of compression - like some pkzip open source or something, and just use the bitmaps to do this trick. But this isn't elegant when you have (like me) some png, some jpg, some bmp, etc etc.

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 28th Dec 2007 11:57
Quote: "but how i can this with png pictures?"


You can not. You can read only windows bitmap (BMP) images using system LoadImage and LoadBitmap functions.

Quote: "When i change the filename IDB_BITMAP1 in etc. IDB_PNG1 the png will not be show"


It's not a filename! It's an identifier of your resource (just a numerical constant defined in resources.h). Mostly it is automatically generated when you add a resource to your project, but you can change it later. It has nothing to do with the resource type though.

Try to tell us what do you need this for. It is not common to load png images from resources, because usually you store only small resources in your executable (icons, cursors etc). It is always better to store bigger images (textures) in separate files. If the image is a little one, you can convert it to .png off-line in any image converting application and add it to your resources as .bmp.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 14:55
Hey temppicek - Been noticing some great posts from you man - and I checked out your web site - SWEET! Hope you stick around!

theplake
16
Years of Service
User Offline
Joined: 30th Nov 2007
Location:
Posted: 29th Dec 2007 14:22
How i can save it in a file?
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 29th Dec 2007 16:58
Not sure what exactly you are trying to do. Save a resource to a separate file? The resource IS a separate file, but embedded to the final executable during build step. You can access it in Visual Studio or on drive as a file... but you are probably up to something else... ?
theplake
16
Years of Service
User Offline
Joined: 30th Nov 2007
Location:
Posted: 30th Dec 2007 17:09
what i try is i will bring the pictures from the example dark invader in the exe or in a seperate file.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2007 17:16
compile that code (source) as is might be all that is neceaary - you said it yourself - wrong exe.

Login to post a reply

Server time is: 2024-11-19 20:29:15
Your offset time is: 2024-11-19 20:29:15