Results 1 to 2 of 2

Thread: Bitblt monochrome conversion

  1. #1
    epic69
    Guest

    Question Bitblt monochrome conversion

    Why does this not work? When the bitblit writes back into the picture1 picbox it is just toally black?

    btmp = CreateBitmapForm1.Picture1.ScaleWidth,Form1.Picture1.ScaleHeight, 1, 1, 0&)
    chdc = CreateCompatibleDC(Form1.Picture1.hDC)
    x = SelectObject(chdc, btmp)
    'store bitmap to DC and then back to picture box this should convert bmp to monochrome format.

    l = BitBlt(chdc, 0, 0, Form1.Picture1.ScaleWidth,
    Form1.Picture1.ScaleHeight, Form1.Picture1.hDC, 0, 0, SRCCOPY)

    l = BitBlt(Form1!Picture2.hDC, 0, 0, Form1.Picture1.ScaleWidth,
    Form1.Picture1.ScaleHeight, chdc, 0, 0, SRCCOPY)
    Form1.Picture2.Refresh
    btmp = SelectObject(chdc, x)
    k = DeleteObject(btmp)
    retval = DeleteDC(chdc)

  2. #2
    Registered User
    Join Date
    May 01
    Location
    taizhou zheziang china
    Posts
    17
    btmp = CreateBitmapForm1.Picture1.ScaleWidth,Form1.Picture1.ScaleHeight, 1, 1, 0&)

    'tyr this:
    'btmp=CreateCompatibleBitmap(.......)
    'don't select an exist bitmap which belong to another DC into a CompatibleDC

    chdc = CreateCompatibleDC(Form1.Picture1.hDC)
    x = SelectObject(chdc, btmp)
    'store bitmap to DC and then back to picture box this should convert bmp to monochrome format.

    l = BitBlt(chdc, 0, 0, Form1.Picture1.ScaleWidth,
    Form1.Picture1.ScaleHeight, Form1.Picture1.hDC, 0, 0, SRCCOPY)

    l = BitBlt(Form1!Picture2.hDC, 0, 0, Form1.Picture1.ScaleWidth,
    Form1.Picture1.ScaleHeight, chdc, 0, 0, SRCCOPY)
    Form1.Picture2.Refresh
    btmp = SelectObject(chdc, x)
    k = DeleteObject(btmp)
    retval = DeleteDC(chdc)

Posting Permissions

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