Page 1 of 2

Bitmap Resource in a LIB

PostPosted: Dec 19, 2003 @ 3:22am
by ppcStudios
I have built a static lib of my RaptureEngine. Within the project I have a resource file which contains a watermark image, so when the library is built this image is supposed to be embedded within it. I then load this bitmap onto a surface and draw it as needed.

The only problem is that CreateSurface() can't locate the bitmap resource. I'm not 100% positive that the resource is even being included in the library even though VC says it is compiling the resources. Has anyone tried doing this before? I did a Google search and only came up with one thread pertaining to the problem, but it had no resolution. Is there any way to make this work?

PostPosted: Dec 19, 2003 @ 4:10am
by fzammetti
Well, this of course isn't the answer your looking for, but thinking in work-around mode...

Could you store your bitmap in an array and during initialization plot it onto a surface? Then just use that surface as you had previously intended to use your watermark surface?

If it's a 256-color image, your just talking about storing an int for each pixel referencing an entry in another array, your palette. Then just plot each point and off you go. A slight delay at startup, but nothing severe. Shouldn't take up much more memory than incorporating a bitmap anyway, even including the extra little bit of code.

Like I said, not the "right" answer, but it might do the trick. As an added bonus, it should make it slightly harder for someone nefarious to change or remove your watermark.

PostPosted: Dec 19, 2003 @ 4:27am
by gersen
I'm pretty sure that you can't include in a .lib a resource file. All the resources are related with exe and dll file format so simply it can't be included in a .lib.

As fzammetti have said you can convert a bitmap in an array and then load it with the
CreateSurface(DWORD dwFlags, BYTE* pImageFileMem, DWORD dwImageFileSize);
passing the array pointer as the pImageFileMem.
For the conversion you can use a tool that I have used thousand of times when I have programmed the gba http://www.devrs.com/gb/files/b2x.zip
With this little app you can convert a file to a C statements. You can convert directly a .png (or the graph format you want) in a static C array and include it on your .lib. Then you can load it with the CreateSurface... oh, I have written this part before :)

PostPosted: Dec 19, 2003 @ 4:28am
by ppcStudios
Actually, I thought of that as an option. I was hoping to keep things simple and find a solution to why the bitmap resource doesn't appear to be included in the lib, but if I can't resolve it pretty quickly I'll probably fall back to this idea.

I noticed one of the CreateSurface interfaces took a BYTE * to the image data. I may explore that avenue further.

edit: Thanks Frank and Thomas!

PostPosted: Dec 19, 2003 @ 4:37am
by ppcStudios
Thomas: That's a pretty slick little program! Do you know if any data needs to be stripped out of the resulting array to work with CreateSurface?

PostPosted: Dec 19, 2003 @ 4:45am
by gersen
No, you can use it as it is with CreateSurface. I love that little program :D

PostPosted: Dec 19, 2003 @ 4:56am
by ppcStudios
I didn't have much luck the first time around. The image was just a huge black block. Do I need to specify to generate 16 bit values?

PostPosted: Dec 19, 2003 @ 5:02am
by ppcStudios
Never mind. I figured it out =)

It appears to work perfectly!

PostPosted: Dec 19, 2003 @ 5:22am
by gersen
Now we are all waiting for the release of your Rapture Engine :D

PostPosted: Dec 19, 2003 @ 5:24am
by ppcStudios

PostPosted: Dec 19, 2003 @ 5:26am
by ppcStudios

PostPosted: Jan 3, 2004 @ 12:45pm
by Johan

PostPosted: Jan 3, 2004 @ 12:55pm
by ppcStudios

PostPosted: Jan 3, 2004 @ 7:08pm
by mlepage

PostPosted: Jul 11, 2004 @ 9:20pm
by abiemann