CreatePatternBrush and screen color depth

Posted by Carlos Alloatti on Stack Overflow See other posts from Stack Overflow or by Carlos Alloatti
Published on 2010-06-04T15:53:14Z Indexed on 2010/06/06 7:22 UTC
Read the original article Hit count: 254

Filed under:
|
|

I am creating a brush using CreatePatternBrush with a bitmap created with CreateBitmap.

The bitmap is 1 pixel wide and 24 pixels tall, I have the RGB value for each pixel, so I create an array of rgbquads and pass that to CreateBitmap.

This works fine when the screen color depth is 32bpp, since the bitmap I create is also 32bpp.

When the screen color depth is not 32bpp, this fails, and I understand why it does, since I should be creating a compatible bitmap instead.

It seems I should use CreateCompatibleBitmap instead, but how do I put the pixel data I have into that bitmap?

I have also read about CreateDIBPatternBrushPt, CreateDIBitmap, CreateDIBSection, etc.

I don´t understand what is a DIBSection, and find the subject generally confusing.

I do understand that I need a bitmap with the same color depth as the screen, but how do I create it having only the 32bpp pixel data?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about api