Results 1 to 7 of 7

Thread: An easy question in DirectX(Direct Draw)

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    An easy question in DirectX(Direct Draw)

    I am a newbie in DX. While creating a surface from a picture file we use Set Surface=DirectDraw.CreateSurfaceFromFile().
    My question is there is also a function DirectDraw.GetSurfaceFromDC() and I want to know how to use this. I tried getting the hDc of a picture box but no luck.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Used this in Delphi a few days ago, don't quite remember the VB way, but since it's all just directx, it should be similar. Therefore, a little pseudo-code:


    VB Code:
    1. '// Set up a DDSURFACEDESC2 with the width & height and stuff,
    2. '// then create an empty surface
    3. Set Surface = DirectDraw.CreateSurface()
    4.  
    5. '// Get DC
    6. DC = Surface.GetDC()
    7.  
    8. '// Draw from source DC onto surface DC
    9. BitBlt(Source, 0, 0, Width, Height, DC, 0, 0, vbSrcCopy)
    10.  
    11. '// Release DC
    12. Surface.ReleaseDC(DC)


    Should work something like that


    [edit]
    oops, used Delphi-style comments
    [/edit]
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I think you're trying to use it the wrong way- you're trying to get the picture from a DC into the Surface, while what that function does is allows you to use the surface in GDI operations. It returns the DC rather than setting it.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    *cough* I need a DC for the BitBlt operation


    [edit]
    I used this technique in Delphi, since a surface doesn't have a CreateFromFile function. I don't know if this is a bad translation of the C header files or that they added that function to the interface for VB... my point: this method is correct


    Interesting, the text functions have disappeared too. I have to manually get the DC and draw the text using TextOut... I think that the VB import library does that too, every time you call it, that's why Surface.TextOut is slow
    [/edit]
    Last edited by PsychoMark; Dec 12th, 2001 at 08:37 AM.
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  5. #5

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    Yeah I was trying to set the DC. Actually I tried using the mask technique to make an area invisible using BitBlt and then set that DC to the surface. I am just a newbie and don't know much in DX. Can anyone give some help.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  6. #6
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Use the SetColorKey function of the surface to get a color transparent


    http://www.vbexplorer.com/directx4vb/ explains it quite good
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  7. #7

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    Thanks, I got it
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

Posting Permissions

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



Click Here to Expand Forum to Full Width