Results 1 to 6 of 6

Thread: BitBlt?

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Hampshire
    Posts
    32
    I really whant to understand how the Api

    (Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long)

    works.

    For one, could some explain to me what hDestDC and hSrcDC is?

  2. #2
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    I'm pretty sure Fox has a tutorial on the subject on his little website of wonderz ;D
    To understand recursion, one must first understand the concept of recursion.

  3. #3
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    hDc is the graphics handle of an object.
    So hDestDC is the graphics handle of the object you are going to BiBlt too an hSrcDC if the graphics handle of the object you going to take the picture from.

    [C]

    Public Const SRCERASE = &H440328 ' (DWORD) dest = source AND (NOT dest )

    Public Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest

    Public Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

    Public Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest

    Public Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest



    BitBlt Form2.hDC, 12, 11, 100, 8, Form1.hDC, 14, 19, SRCCOPY

    Form2.hDc = The graphics handle of Form2( in this case Form2 is the destination of the the picture) _

    12 = X cordinate on the Form2 where we are going to put the_ picture _

    11= The Y cordinate of where we are going to put the picture_

    100= the Width of the picture we are going to take._

    8= The height of the picture we are going to take._

    Form1.hDc= The Graphics handle of Form1_

    14= The x cordinate of the picture on form1(ie The left end of the picture = the x cordinate)

    19= The Y cordinate of the picture on form1( ie the Top of the picture = the y cordinate)

    SRCCOPY= Copy the picture onto the destination.

    [/C]


    Hope that made sense.

    All spelling errors are undocumented features.

    How do you do code tags?

    [Edited by Bjwbell on 12-09-2000 at 02:51 AM]
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    DC stands for Device Context, which is a Windows thing. hDC means a handle to a device context, which is another Windows thing and is essentially an integer ID for that device context. In most cases when you come across or use DCs, they will be graphics device contexts, because they'll be to do with graphics on the screen, although it is also possible to get DCs relevant to things like printers.

    hSrcDC in this case would probably be the .hDC property of a control in the area of the screen you want to draw an image of somewhere else, or if the control doesn't have that property then you can sort of borrow one using the GetDC API call, then use ReleaseDC when you've finished with it.

    hDestDC is just the same but the hDC of the place you're going to put the image.

    X and Y are the coordinates, in pixels, within that control (which is actually a window itself as far as Windows is concerned) where you want to put the top-left corner of the image. nWidth and nHeight are the height and width of the image, in pixels. You should note that in Windows' coordinate system, Y increases downwards, X increases to the right, and the origin (0, 0) is in the top-left corner.

    xSrc and ySrc are the coordinates, within the source control (a window) which you specified with hSrcDC from, which are the top-left corner of your source image.

    dwRop is a constant representing what kind of raster operation you want performed. This is basically how you want the image data to be copied. You will probably just want to put the constant dwSrcCopy in there which will put an exact copy of the image there. The constants are there in the VB help if you look around for them. There are others that will copy some pixels but not others, or that will change the colours according to some different rules, but I don't think you need to use them yet.

    As DarkMoose said, Fox has some good demos on his website for learning the basics (and not-so-basics) of games programming in VB, so go and take a look. I know for certain he has a BitBlt demo as I was one of his first customers for it Take a look at it here: Fox's site
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Use [code] and [/code]
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154

    Smile

    Thanks.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

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