Announcement

Collapse
No announcement yet.

Bitmap format when pasting 32bit DIB from clipboard?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bitmap format when pasting 32bit DIB from clipboard?

    I'm trying to save a DIB (%CF_DIB) bitmap from the clipboard, which works great for all bit depths except 32 bits per pixel. I can't seem to calculate the proper start of the bitmap data for that depth.

    I get the 40 byte header (as read from the header_size) field.

    According to the documentation I can find, when the compression field is set to BI_BITFIELDS the header should be followed by three DWORD masks. This should equal 6 bytes, right? Which means the bitmap data should start 6 bytes after the header (there's no color table with a 32 bit depth bitmap, right?)

    Unfortunately, the data is not where I'm expecting it to be. What am I missing?

    I tried using the %CF_BITMAP method instead, but EVERY image ends up as a 32 bit depth image.

    Using the %CF_DIB method I can retain lower bit depth images, but the 32bpp image (such as using the Prnt/Scrn button on the keyboard) comes through invalid.

    I'm obviously overlooking something. Any ideas?

    Thanks,

    Anthony
    Anthony Watson, Mountain Software
    www.mountainsoftware.com

  • #2
    [...] three DWORD masks. This should equal 6 bytes, right?
    Wrong. 3 * 4 = 12.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Code:
      Wrong. 3 * 4 = 12.
      Thanks for the correction. You're right, of course, but I still wasn't ending up with a usable DIB. For a 32bit DIB with BI_BITFIELDS compression, I was assuming the packed bitmap should be:

      40 Bytes for the BitmapInfoHeader
      12 Bytes for the Color Masks
      ...The start of the bitmap data

      In my case, I had no interest in the color masks, and I stumbled across the solution this morning. If I'm no longer using the color masks, I have to change the compression field from BI_BITFIELDS to BI_RGB. Bingo! Works like a charm now.

      Thank you for the clarification. I figured it was just something simple I was overlooking.

      Anthony
      Anthony Watson, Mountain Software
      www.mountainsoftware.com

      Comment

      Working...
      X