• Advertisement

Archived

This topic is now archived and is closed to further replies.

hiding a bitmap from the user

This topic is 5747 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

Hi I want to hide the bitmap that is used as a texture from the user. Here what I did I created a resource file in my project, then I inserted a bitmap. MSVC++ installed a blank bitmap with the name IDB_BITMAP1, I copied and pasted to that blank bitmap the bitmap I wanted.(I inserted resource.h to the project) This bitmap is supposed to be a texture as follows. D3DXCreateTextureFromFile( g_pd3dDevice,"banana.bmp",&g_pTexture ) Now how do I modify the code to get the texture from IDB_BITMAP1 instead of getting the texture from banana.bmp Best regards If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
D3DXCreateTextureFromResource(
g_pd3dDevice, NULL, IDB_BITMAP1,&g_pTexture )

Share this post


Link to post
Share on other sites
Thanks Anonymous Poster I am getting closer

I am not sure about how to solve this error(below) after I modified the code as above.

My best regards
--------------------Configuration: Textures - Win32 Debug--------------------
Compiling...
Textures.cpp
D:\MySamples\Tut05_Textures\Textures.cpp(114) : error C2664: ''D3DXCreateTextureFromResourceA'' : cannot convert parameter 3 from ''const int'' to ''const char *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
It is working now.

My best regards


If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
quote:
Original post by OB1st
I want to hide the bitmap that is used as a texture from the user.



Why?

There are programs that allow you to view resources inside exe files, one of them being MSVC IDE. People who want to use your textures for something will certainly find a way to extract them out of your exe file.

Some commercial games, such as Quake, don''t hide their textures at all. However, if you really want to hide something, use your own container file (a big file that stores smaller files) or even your own bitmap/model format.

But then again, what are you afraid of?

Share this post


Link to post
Share on other sites
I did not mean to hide it because of greed. I ment to hide it for convinience.

However I still have a problem.

I e-mailed the executable to a friend without e-mailing the bit map file. the bitmap file was automaticly generated during compilation which defeats the purpose of imbeding a bitmap into a resource.

I fail to see this as a real resource, what MSVC++ is doing is just mapping the information to the separate bitmap file via the resource configuration.

Am I missing something


If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
I forgot to mention that when I e-mailed the executable to my friend, it did not run because I did not e-mail the bitmap file that MSVC++ generated. Actually at the time I did not even know that MSVC++ has generated a bitmap file because I thought a resource file lives inside the executable.

Thanks




If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
Umm.. let me clear a couple things here.

A "resource file" (.rc) is a text file that can either store resources in text format OR store references to files that contain resources in possibly bitmap format. In your case, you most likely had a reference to a bitmap:

IDB_BITMAP1 BITMAP "somebitmap.bmp"

The bitmap isn''t actually stored in the resource file.

When you compile resources, you get a .res file. In that file you have all program resources. In case of menus or dialog boxes, they are convertex from text to binary. If you have an external bitmap, however, bitmap data is just copied to the .res file. Open it in a binary viewer and look inside.

When you''re linking, the .res file is appended to the .exe file, mostly or at all unchanged. You can extract individual resources from the exe file, as well as add and remove resources to an exe file once it''s built. Some fun I had a while ago was to replace dialog boxes in Program Manager in Windows 3.1.

You need the original bitmaps to build the exe file if your .rc file stores references to bitmaps. You don''t need original bitmaps if your .rc file has the bitmaps in text format. You don''t need the bitmaps to run the exe file if you''re loading bitmaps from the exe.

Share this post


Link to post
Share on other sites
Thanks for the reply

indirectX wrote:
(You don''t need original bitmaps if your .rc file has the bitmaps in text format).

How do I include my bitmap file in the project in text format, and therfore not have to e-mail it with the executable for others to run it.

My best regards



If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
quote:
Original post by OB1st
How do I include my bitmap file in the project in text format, and therfore not have to e-mail it with the executable for others to run it.



Do you suppose by including the bitmap as text in your .rc file the size of the latter won't grow? In fact, a byte can have 256 values while a character only 96. So by storing bitmap data as text, you'll need more space. There's little point in storing bitmaps as text in resource files. Just distribute your bitmaps with your projects like everyone does.

You don't need to distribute the bitmap files with your executable, since they are already in the executable. If you can't load them from .exe, you're doing something wrong.

Also consider using compressed file formats, if you aren't already doing so. JPEGs are nice if you can live with losses, otherwise go with PNGs. D3DX can load them, so why waste space for uncompressed bitmaps?

[edited by - IndirectX on June 2, 2002 7:09:29 AM]

Share this post


Link to post
Share on other sites
Thanks for the usefull discussion.



If love is illusion and hate is real, I would rather be crazy

Share this post


Link to post
Share on other sites
Ironblayde brought up this topic in the Game Programming Genesis series: "You don''t want anyone to change your beautifully scripted end scene to a version of ''all your base are belong to us'', do you?", he said. True enough. As I see it, the best solution (as previously mentioned) is to generate a pack file where you store all your resources, and then access the pack file and extract resources from it run-time, much like Blizzard''s MPQ format or .PAK files in quake.

There is a great code example of this in Chris Hargrove''s Code on the Cob series here on gamedev. It is pretty tough code that takes some skill to understand, though.

Besides, to store things in resources often isn''t a good solution. There is no reason to make things platform-dependent when you can avoid it.

Share this post


Link to post
Share on other sites

  • Advertisement