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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:08:52+00:00 2026-06-18T12:08:52+00:00

I have the BITMAPFILEHEADER, BITMAPINFOHEADER, and the image data of a bitmap stored in

  • 0

I have the BITMAPFILEHEADER, BITMAPINFOHEADER, and the image data of a bitmap stored in variables named, say, bf, bi, and imageData, respectively. When I output these to a .bmp file, I can open it without problem and view the image. I can also write some code to import this bmp file and display it in my dialog box.

My question is: is there an easy way to cut out the middle man and take my BITMAPFILEHEADER, BITMAPINFOHEADER, and image data and directly write these data into a 24 bitmap image displayed in the dialog box, without the need of using an external file?

For reference, here is the code I’m using now to output to a file, then input this file into the dialog box:

    //fileheader
    BITMAPFILEHEADER* bf = new BITMAPFILEHEADER;
    bf->bfType = 0x4d42;
    bf->bfSize = 6054400 + 54;
    bf->bfOffBits = 54;

    //infoheader
    BITMAPINFOHEADER* bi = new BITMAPINFOHEADER;
    bi->biSize = 40;
    bi->biWidth = 2752;
    bi->biHeight = -733;
    bi->biPlanes = 1;
    bi->biBitCount = 24;
    bi->biCompression = 0;
    bi->biSizeImage = 6054400;
    bi->biXPelsPerMeter = 2835;
    bi->biYPelsPerMeter = 2835;
    bi->biClrUsed = 0;
    bi->biClrImportant = 0;

    //image data
    unsigned char* imageData = new unsigned char[6054400];
    pFrame->GetImage(imageData);


    //////////////////////////////////////////////////////////////////////////
    //////////  Output to .bmp File   ////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////


    std::ofstream outFile;

    outFile.open("test.bmp", std::ios::binary|std::ios::out);

    outFile.write(reinterpret_cast<char *>(bf), sizeof(BITMAPFILEHEADER));
    outFile.write(reinterpret_cast<char *>(bi), sizeof(BITMAPINFOHEADER));
    outFile.write(reinterpret_cast<char *>(imageData), 6054400);

    outFile.close();

    //////////////////////////////////////////////////////////////////////////
    //////////  input .bmp and print to dialog box   /////////////////////////
    //////////////////////////////////////////////////////////////////////////

    CString szFilename ("C:/dev/NanoDev/TestApps/AVT_Testapp/test.bmp");
    HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
    CBitmap bmp;
    bmp.Attach(hBmp);
    CClientDC dc(this);
    CDC bmDC;
    bmDC.CreateCompatibleDC(&dc);
    CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
    BITMAP  bi;
    bmp.GetBitmap(&bi);
    dc.BitBlt(384,26,bi.bmWidth/3,bi.bmHeight,&bmDC,0,0,SRCCOPY);
    bmDC.SelectObject(pOldbmp);
  • 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-06-18T12:08:53+00:00Added an answer on June 18, 2026 at 12:08 pm

    You can use the StretchDIBits function to draw directly from memory to a DC. You’ll just need to convert your data from a BITMAPINFOHEADER to a BITMAPINFO structure.

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

Sidebar

Related Questions

I am extremely new to manipulating bitmap data in C++, and I have a
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
have a nice day. I got problem when trying to create an image from
Have a photography site that I want to prevent image copying from. How can
have a little question concerning image icons in java and how to put a
Have a text box which get data for price. If someone enter something like
I'm trying to read a BMP image (greyscales) with C, save values into an
Thank you in advance! I'm reading a BMP in C++ using self-defined BITMAPFILEHEADER and
Have defined such class: class Data { internal string f_source; internal string f_output; internal
have written this little class, which generates a UUID every time an object of

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.