Jump to content
  • Advertisement

Archived

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

OB1st

hiding a bitmap from the user

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

  • 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!