Jump to content
  • Advertisement
Sign in to follow this  

D3D, PNG img format, and Resources!?

This topic is 4721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok everyone, I was wondering how to make my images go inside my exe file (aka resources); that way it would be a bit more professional; i used to do this all the time with my bmp images, but is there anyway to do it with png? i started using png b/c every1 suggested it for transparency... thanx [Edited by - -justin- on June 16, 2005 5:57:10 PM]

Share this post


Link to post
Share on other sites
Advertisement
Just import the .png into your resource script (as a custom resource) and use D3DXCreateTextureFromResource or D3DXCreateTextureFromResourceEx to load it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
Just import the .png into your resource script (as a custom resource) and use D3DXCreateTextureFromResource or D3DXCreateTextureFromResourceEx to load it.


hmm, i hate to sound stupid but here's what i did

i imported my png file as a custom resource named "png"...

then i used D3DXCreateTextureFromResource(device, NULL, MAKEINTRESOURCE(IDR_PNG2), &ptrToTexture);

what did i do wrong? I get a load texture error...

i looked up documentation on D3DXCreateTextureFromResource, it says my resource has to be of type RT_BITMAP or RT_RCDATA, obviously i don't want the RT_BITMAP type, but i'm not sure if what i did was correct doing the RT_RCDATA....

i'm still a lil new to resources...thx

Share this post


Link to post
Share on other sites
Check your resource script and make sure it created a resource of type RT_RCDATA. (Open it in a text editor to be sure). If not, then you may have to do a bit of manual work to get it in that way.

I was being a bit smug when replying, since I've not actually tried this myself. ;) I'll take a closer look when I get home this evening and see if there is something funky you need to do.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
Check your resource script and make sure it created a resource of type RT_RCDATA. (Open it in a text editor to be sure). If not, then you may have to do a bit of manual work to get it in that way.

I was being a bit smug when replying, since I've not actually tried this myself. ;) I'll take a closer look when I get home this evening and see if there is something funky you need to do.


Heh, thanks for your help dave. Yea I'm not quite sure what to do now, I'm thinking obviously the problem is that it's not a RT_RCDATA type; but I'm not sure HOW to make it that type. I'll keep working on it but if you think of anything let me know!!

Kind Regards,
~j

Share this post


Link to post
Share on other sites
Ok so I created my own .rc file

then after searching through many sites I found something that looked promising...

I thought I could just do:

ID_IDNAME RCDATA path/to/file

but i get errors when i do that...

so i'm confused; i'm goin to keep workin' on this, but again if any1 can help that'd be great...

Share this post


Link to post
Share on other sites
I was able to do an Import resource. I right-clicked on the resource script, selected Add Resource..., selected Import..., pointed at the jpg file I wanted, and then typed RCDATA when it prompted for the type. The resource compiler handled it just fine and it looks like the image is embedded in the exe correctly. I haven't tried loading it with D3DXCreateTextureFromResource, but it looks like it should work.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
I was able to do an Import resource. I right-clicked on the resource script, selected Add Resource..., selected Import..., pointed at the jpg file I wanted, and then typed RCDATA when it prompted for the type. The resource compiler handled it just fine and it looks like the image is embedded in the exe correctly. I haven't tried loading it with D3DXCreateTextureFromResource, but it looks like it should work.


OMG i coulda swore i did that... gah... well, i did it and it works... i'm now ready to release my game... go me :P

Thank you!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!