Jump to content

  • Log In with Google      Sign In   
  • Create Account


Bitmap Load


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 11 February 2000 - 06:37 AM

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.

Sponsor:

#2 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 11 February 2000 - 10:56 AM

Any answer would be reassuring.

#3 LeeIsMe   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2000 - 11:29 AM

Use the direct3dx utility library. It has a function called D3DXCreateTextureFromFile that can load a bitmap to a surface.

#4 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 11 February 2000 - 11:31 AM

Thanks, but I''m programming in directdraw, not direct3d.

#5 +AA_970+   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2000 - 11:37 AM

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.


#6 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 12 February 2000 - 01:32 AM

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.

#7 Cloxs   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 02:05 AM

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.

#8 Staffan   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 02:54 AM

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

#9 Facehat   Members   -  Reputation: 696

Like
Likes
Like

Posted 12 February 2000 - 03:11 AM

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

#10 +AA_970+   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 February 2000 - 03:41 AM

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

#11 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 13 February 2000 - 05:47 AM

thanks for helping me out. After this, would I just blit from the surface that it is loaded to?

#12 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 13 February 2000 - 08:40 AM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS