Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 847241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:45:04+00:00 2026-05-15T06:45:04+00:00

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

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:45:05+00:00Added an answer on May 15, 2026 at 6:45 am

    You could create a DIB because you can use a Device Independent Bitmap independently of the screen color depth. See CreateDIBSection().

    How can you create it having only the 32bpp pixel data? A DIB can be created with 32bpp data. As you can read in the documentation:

    The CreateDIBSection function creates
    a DIB that applications can write to
    directly. The function gives you a
    pointer to the location of the bitmap
    bit values.
    If hSection is NULL, the system
    allocates memory for the DIB. If the
    function succeeds, the return value is
    a handle to the newly created DIB, and
    *ppvBits points to the bitmap bit values.

    Try something like this:

    VOID *ppvBits = NULL;
    BITMAPINFO BitmapInfo;
    memset(&BitmapInfo, 0, sizeof(BITMAPINFOHEADER));
    BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    BitmapInfo.bmiHeader.biWidth = 1;
    BitmapInfo.bmiHeader.biHeight = 24;
    BitmapInfo.bmiHeader.biPlanes = 1;
    BitmapInfo.bmiHeader.biBitCount = 32;
    BitmapInfo.bmiHeader.biCompression = BI_RGB;
    HBITMAP hBitmap = CreateDIBSection(hDC, &BitmapInfo, DIB_RGB_COLORS, &ppvBits, NULL, 0);
    

    In our case *ppvBits points to 1 * 24 * (32 / 8) allocated bytes.

    It is important to know that if biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. See BITMAPINFOHEADER Structure for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 419k
  • Answers 419k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What I want now is that the English main.strings is… May 15, 2026 at 10:28 am
  • Editorial Team
    Editorial Team added an answer Yes there is definitely a performance gain from not supplying… May 15, 2026 at 10:28 am
  • Editorial Team
    Editorial Team added an answer Dont use spaces: SET @var="GREG" ::instead of SET @var =… May 15, 2026 at 10:28 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.