Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

-Fruz-

DIB Section creation blanks the hDC ?

This topic is 5662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am trying to save the hdc to a bitmap file, and i''m trying to: create a dib section with the dc, combining it with the dc, and then get the pixels from that dc with getdibits, and then save the bmp header stuff to the file, followed by the pixels. Code:
    Dim bmpH As BITMAPINFO_NoC
    With bmpH.bmiHeader
        .biBitCount = 32
        .biPlanes = 1
        .biSize = Len(bmpH.bmiHeader)
        .biWidth = W
        .biHeight = H
        .biSizeImage = (W * 4) * H
    End With

    Dim tBM As Long
    tBM = CreateDIBSection(hDc, bmpH, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
    Call SelectObject(hDc, tBM)

    Dim Pixel() As Byte
    ReDim Pixel(1 To 4, 1 To W, 1 To H)
    GetDIBits hDc, tBM, 0, H, Pixel(1, 1, 1), bmpH, DIB_RGB_COLORS

    Dim BMPHeader As BITMAPFILEHEADER
    BMPHeader.bfType = &H4D42
    BMPHeader.bfOffBits = Len(BMPHeader) + Len(bmpH.bmiHeader)
    BMPHeader.bfSize = BMPHeader.bfOffBits + bmpH.bmiHeader.biSizeImage

    Open File For Binary As #1
    Put #1, , BMPHeader
    Put #1, , bmpH
    Put #1, , Pixel
    Close #1
i know it may be hard to notice anything by just looking at this code, but, if you have done something like this in the past, is there something i should know? thanx

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!