Bitmap Load
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.
D:
Use the direct3dx utility library. It has a function called D3DXCreateTextureFromFile that can load a bitmap to a surface.
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.
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.
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.
D:
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.
![](smile.gif)
Hope this helped - Cloxs
My finger can point you to the moon,
but you do not need my finger to know it is there.
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 ![](wink.gif)
-- Staffan
![](smile.gif)
![](smile.gif)
![](wink.gif)
-- Staffan
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
Hmm, thinking about it, I think thats how DDLoadBitmap does it.
--TheGoop
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![](wink.gif)
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![](smile.gif)
Edited by - +AA_970+ on 2/12/00 10:00:20 AM
ok that's a little confusing i know
![](wink.gif)
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
![](smile.gif)
Edited by - +AA_970+ on 2/12/00 10:00:20 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement