Results 1 to 3 of 3

Thread: Newbie: Writing a TBITMAP to a surface

  1. #1

    Newbie: Writing a TBITMAP to a surface

    Hi,

    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?

  2. #2

    Newbie: Writing a TBITMAP to a surface

    ...about 10 minutes later I think I've worked it out, it appears to work anyway!

  3. #3

    Newbie: Writing a TBITMAP to a surface

    It's always a good idea to say how you solved it so others can benefit from it.

    Anyway here's how I do it (without being an expert at DirectDraw):
    [pascal]if FAILED(FSurface.GetDC(SurfaceDC)) then Exit;
    try
    if not BitBlt(SurfaceDC, 0, 0, FWidth, FHeight, FBitmap.Canvas.Handle, 0, 0, SRCCOPY) then Exit;
    finally
    FSurface.ReleaseDC(SurfaceDC);
    end;
    [/pascal]
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •