Archived

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

Bitmap Load

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

What, do you consider, the best way to load a bitmap. I am really nwe to directdraw and have not been able to load a bitmap comfortably even using the source from the books. The coding doesn''t seem to feel right. So if anyone has any ideas please send me some code for functions to load bitmaps to the backbuffer. Thanks.

Share this post


Link to post
Share on other sites
Use the direct3dx utility library. It has a function called D3DXCreateTextureFromFile that can load a bitmap to a surface.

Share this post


Link to post
Share on other sites
well u can use microsoft''s DDLoadBitmap function within ddutil.cpp and ddutil.h

copy the two files to your project''s directory and add them to the proj. and compile them.

to load a bitmap just do something like:

DirectDrawSurface = DDLoadBitmap(directdrawobject,pathofbitmap, sx, sy);

sx and sy are for if u want to stretch the bitmap if u don''t put put 0 else put a value less then the size of the screen.

to load the image to the back buffer do a blt or bltfast operation, something like:

g_pDDSBack->BltFast(x,y,DirectDrawSurface,&rcRect,FLAGS);

g_pDDSBack is your back buffer
x & y are where u want the image on the screen
DirectDrawSurface is the surface with the bitmap
&rcRect is a rectangle defining how much of the bitmap to show, do something like:

RECT rcRect={0,0,width_of_bitmap,height_of_bitmap);

FLAGS are flags for transparency and stuff check the docs and you''ll find them all.

That''s it and remember to release the surface:

DirectDrawSurface->Release();
DirectDrawSurface=NULL;

when your exiting your app.

Share this post


Link to post
Share on other sites
Thanks a lot. You really helped me out. But, in DDLoadBitmap, what is the "pathofbitmap" parameter? If it is the directory of the bitmap, then I don''t think that It''s worth it. But if it''s just the name, the function seems useful.

Share this post


Link to post
Share on other sites
I think your confused . The path is any sort of refrence to a file, from the current directory or root(c:\ for you windows people). So, if your running your game from the c:\mygame directory, and you want to load c:\mygame\thisimg.bmp then set pathname to thisimg.bmp

Hope this helped - Cloxs

My finger can point you to the moon,
but you do not need my finger to know it is there.

Share this post


Link to post
Share on other sites
DDLoadBitmap works fairly good, but what if you want to load it from a resource file (not a windows resource file, but one of those..well..ah..go read that article on here )? Or is there some parameter of it I didn''t figure out yet? Perhaps. However I still prefer doing ut myself (in asm, yeah ) - don''t like using other people code

-- Staffan

Share this post


Link to post
Share on other sites
I personally like to use the Windows GDI functions to load in bitmaps. It automatically does color conversion and all that great stuff. Besides that, you can also load stuff from resource files.

Hmm, thinking about it, I think thats how DDLoadBitmap does it.

--TheGoop

Share this post


Link to post
Share on other sites
by "pathofbitmap" i actually meant the the sub-directory the bitmap is in (if there is one) followed by the filename of the bitmap
ok that's a little confusing i know

basically, the folder your exe is in is usually your woking directory. if the bitmap is in this directory just put
"name_of_bitmap.bmp"

however, if there is a sub-directory to the main directory, like if u have a sub-directory named "gfx" to put all the graphics for your game, you would put
"name_of_sub-directory\\name_of_bitmap.bmp"

i hope this helps

Edited by - +AA_970+ on 2/12/00 10:00:20 AM

Share this post


Link to post
Share on other sites
I thank you for all replying to my post and I appreciate the information that you have all given. But what if I''m using my own code? What do you consider the best way to load a bitmap then?

Share this post


Link to post
Share on other sites