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 800963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:22:15+00:00 2026-05-14T23:22:15+00:00

I am just starting out with win32 GDI programming and finding good references hard

  • 0

I am just starting out with win32 GDI programming and finding good references hard to come by. I have a simple application that captures the screen by doing the following:

UINT32 x,y;
x = GetSystemMetrics(SM_CXSCREEN);
y = GetSystemMetrics(SM_CYSCREEN);

HDC hdc = GetDC(NULL);
HDC hdcScreen = CreateCompatibleDC(hdc);

HBITMAP hbmp = CreateCompatibleBitmap(hdc, x, y);

SelectObject(hdcScreen, hbmp);

BitBlt(hdcScreen, 0, 0, x, y, hdc, 0, 0, SRCCOPY)

ReleaseDC(NULL, hdc);

I am capturing a compatible bitmap which on my machine is 32-bit. Using same/similar calls how would I capture the screen in 8-bit? What about as 16-bit?

  • 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-14T23:22:15+00:00Added an answer on May 14, 2026 at 11:22 pm

    Use CreateDIBSection to create a 8bpp bitmap, and BitBlt onto that.


    Filling in the BITMAPINFO structure is going to be the interesting. You can’t use a normal BITMAPINFO struct as it only allocates space for a single palette entry and, with a 8bpp image – you will need the full 256 entries.

    If you want to cheat a bit, one can use a anonymous union to declare a BITMAPINFO with enough space for its palette.

    union
    {
      BITMAPINFO bmi;
      struct {
        BITMAPINFOHEADER bmih;
        RGBQUAD extra[256];
      } dummy;
    };
    
    bmi.bmiHeader.biSize = sizeof (bmi.bmiHeader);
    bmi.biBitCount = 8;
    // and so on.
    

    As to the values to initialize in the color table… I can’t think of an easy way to get a default 8bpp palette from GDI when its not in 8bpp mode. I have a suspicion that CreateHalftonePalette isn’t going to do anything on a non palette device.

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

Sidebar

Related Questions

Just starting out with an iPhone application using xcode 4.2. I understand that it
Just starting out with C#, so this may be overly simple that I keep
I'm just starting out with Python, and have found out that I can import
Just starting out here, I have a Article.rb model that stores articles. So it
Just starting out with ASP.NET MVC and have come across a stumbling block already.
Just starting out with subversion, have set up repos for 3 current projects and
Just starting out, this should be a simple one but I haven't been able
I'm just starting out in Java, and only ever used PHP before - finding
I am just starting to learn JNI. I have been following a simple example,
Just starting out with my first commercial app for the iStore but dont have

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.