Jump to content

  • Log In with Google      Sign In   
  • Create Account

I need help with bitmaps & directdraw


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
5 replies to this topic

#1 AcidJazz   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 08:54 PM

Okay, I understand how to initialize directdraw, and all the surfaces and flipping, but i don't really understand the whole bitmap part. I got some code from a guy and he created two HDCs and a HBITMAP and adsljkf grrr i just dont get it. Can someone explain HDC and HBITMAP and everything else there is in a process of displaying bitmaps to a surface. Do you need a HDC for every bitmap you display on the screen? grrr plz help hehe

Thanks, AcidJazz

P.S. If you wouldn't mind helping me a little one on one, just add me to your icq list, my uin is 16357086. If you have aim, my sn is AcidJazz13 Thanks again


Sponsor:

#2 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 02:58 PM

Well, the HDC and HBITMAP are just part of a way of using Windows GDI functions to help you load a bitmap from a file. Once you load the bitmap in, you can copy it to a DirectDraw surface and be done with the HDC and HBITMAP - you don't need to keep them around.

- Splat


#3 AcidJazz   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 03:03 PM

okay, how do you use hdc and hbitmap? I mean like how do you load them into memory then load them into a surface. My directx book doesn't cover hdc and hbitmap so grrr

#4 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 03:17 PM

A couple things: First off, does your book even cover loading bitmaps? It should - if it doesn't its not very good.

Second, if you have the DirectX SDK installed, a sample file I believe called "ddutil.cpp" (never used it) contains a function DDReLoadBitmap() which handles taking a bitmap file and dumping the information correctly into a DirectDraw surface. You could either use that function or read it and learn how to do it yourself.

- Splat


#5 Matthew Allen   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 03:23 PM

Ok, so you have DirectDraw set up and you want to load a bitmap and display it on the screen, right? It's really easy, there's only a couple of steps you need to follow:
1. Create a surface for the bitmap.
2. Load the bitmap into the surface.
3. Blit the bitmap onto the back buffer.
4. Flip the back buffer to the primary surface. (you can do this, right?)

1. and 2.
Luckily, Microsoft made a function that creates an offscreen surface and loads a bitmap into it: DDLoadBitmap(). To use this, though, you need to get the files "ddutil.cpp" and "ddutil.h" from the DirectDraw SDK. If you don't have them and want em, I can send them to you.
Now, after you've included the ddutil.h file, call DDLoadBitmap() like this:

LPDIRECTDRAWSURFACE4 lpDDSBitmap = NULL;

if ( ( lpDDSBitmap = DDLoadBitmap( lpDD, "bitmap.bmp", 0, 0) ) == NULL )
return FALSE;

Now the bitmap is loaded into lpDDSBitmap!

3.
To blit the bitmap onto the back buffer, call BltFast():

RECT rcFrom;
rcFrom.left = 0;
rcFrom.top = 0;
rcFrom.right = BITMAP_WIDTH;
rcFrom.bottom = BITMAP_HEIGHT;

if ( FAILED( lpDDSBack->BltFast( 0, 0, lpDDSBitmap, &rcFrom, DDBLTFAST_WAIT ) ) )
return FALSE;

What the DDLoadBitmap() function does is creates a HBITMAP and a DirectDraw sufrace, uses a Windows function (LoadImage()) to load the bitmap from a resource or a file into the HBITMAP, then blits the bitmap from the HBITMAP to the DirectDraw Surface using another Windows function (StretchBlt()).

If you need any more help, send me and email or post to this thread.

I would suggest that you look over the function really well before you use it so you know what it's doing...

------------------
- mallen22@concentric.net
- http://members.tripod.com/mxf_entertainment/

[This message has been edited by Matthew Allen (edited November 04, 1999).]


#6 Matt   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 November 1999 - 08:54 PM

Really you don't have to know or care about HBITMAPS or nearly any GDI object.

As another poster said, if you want to load bmp files, there is a function which does it for you, so you can just live in ignorant bliss =)

You can think of a DC ( a device context) as just that, the state of a particular device, like the screen you are reading this off of, or a printer.

A HBITMAP is basically a handle to a bitmap, be it a blank memory buffer, or if you get it from a DC, a copy of that contexts "output" or display.





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