View Full Version : Newbie: Writing a TBITMAP to a surface

25-10-2004, 12:29 PM

Complete newbie again so no shouting please!.

As you might have seen from my other posts, I?_Tve been using DelphiX for a long time and thought it would be a good idea to learn a little more about the actual workings of DirectX.

After a lot of messing around I thought I?_Td have a look at the code from Clootie?_Ts site and I?_Tve been looking at his DirectDraw examples to try and learn whats going on.

I?_Tve always found the best way of learning something new is to experiment yourself, and by looking at the examples I?_Tm doing my best to work out what?_Ts going on. Far harder than I thought though.

The problem of course is DelphiX makes things so much easier, and that?_Ts where I?_Tm getting very confused in my experimenting.

For a start, how on earth do I write a TBITMAP onto a DirectDraw surface?! And can I write a TBITMAP directly to the backbuffer (even if slower still useful to do easily)?

There is a nice procedure in DDUTILS.PAS to create a surface from a .bmp file, but I can?_Tt for the life of my work out how to simply create one from an existing TBITMAP.

Can someone give me an example or point me in the right direction please?

25-10-2004, 12:43 PM
...about 10 minutes later I think I've worked it out, it appears to work anyway!

25-10-2004, 08:20 PM
It's always a good idea to say how you solved it so others can benefit from it. :wink:

Anyway here's how I do it (without being an expert at DirectDraw):
if FAILED(FSurface.GetDC(SurfaceDC)) then Exit;
if not BitBlt(SurfaceDC, 0, 0, FWidth, FHeight, FBitmap.Canvas.Handle, 0, 0, SRCCOPY) then Exit;