Loading an image from a resource

Posted By: BES

Loading an image from a resource - 01/08/09 18:39

In project A, I BIND a number of images to the project in the wdl: BIND "myimage.png"; etc. When I publish (and check the the resource box in the publish properties) I see my images listed. I copy the resulting wrs to project B. In project B, I try to load the image into a BMAP* with bmap_load:
bmap_load( myBMapPointer, "myimage.png",1);
But I get a d3dx error when I run my script.

How can I retrieve my image? (i.e. do I need to unpack it somehow?)

Thanks for any help!
Posted By: MrGuest

Re: Loading an image from a resource - 01/09/09 11:07

have you added the resource to project B in code, or just placed it in the folder

Code:
RESOURCE "mybmaps.wrs";

Posted By: BES

Re: Loading an image from a resource - 01/09/09 18:34

Currently, I just place the wrs in the folder, and it gets listed in the startup window, and I successfully load levels (wmbs) from within the wrs. I just can't figure out how to get a BMAP* to an image BINDed to the wrs. From the docs:
Quote:
A resource file does not consume memory. Only when a file is read out of a resource, memory is allocated.


I've tried numerous variations of file_load, file_cpy, bmap_load, etc.

As an aside, I'd like to use add_resource() since I'd like to place the wrs in a sub-folder, but when I do that my app can't even retrieve the level's models from the wrs. I can't use the RESOURCE statement in the wdl for project B, cause I need to be able to load additional wdls dynamically. If project B has to know about the wdls at publish time, then the utility of resource files is mostly lost, at least in terms of our project's needs.
Posted By: DavidLancaster

Re: Loading an image from a resource - 01/10/09 10:18

Hey Mark!

This is an untested guess.

BMAP* bmap_name = "bmap_name.png";

You'll have to define it that way and it should work, it means you have to write that for every image that exists and that all images will be preloaded on startup.

Regards,

David
Posted By: BES

Re: Loading an image from a resource - 01/11/09 01:12

lol, I was just going to try that =). My only concern is that you have to know all the bmap names in the loading project, which kind of defeats the purpose. I can try to name elements the same in each loaded wdl, but then I'll have to differentiate between them somehow to access the right one. I think the docs say that the most recent wdl takes precedence. Is there some way to close a resource maybe?
Posted By: Mysterious

Re: Loading an image from a resource - 08/05/09 08:33

Manual says:
"All added folders, resources, and buffers are removed through the add_new function. "

hope this help
© 2024 lite-C Forums