EDN Admin
Well-known member
In an existing Visual Studio 2005 MFC C++ Project, We have managed to convert an image generated at runtime into a 8 Bit Color Bitmap using DIB_RGB_COLORS from pointers that point to the 8 Bit Color Bitmap image in memory.<br/>
<br/>
Code Fragment: (Assume all the variables below are properly typed and properly initialized!)<br/>
---<br/>
// mOurPictureBox contains a Dummy image at the same size as the image that will be replacing it below!<br/>
.<br/>
.<br/>
.<br/>
CDC* pdc = mOurPictureBox.GetDC();<br/>
<br/>
// Move our dummy image into the HBITMAP that<br/>
// we will use to place the Generated at Runtime Image<br/>
HBITMAP hbm = (HBITMAP) mOurPictureBox.GetBitmap();<br/>
<br/>
// Move the Generated at Runtime Image using our Device Context into our HBITMAP Object<br/>
SetDIBits(pdc->m_hDC, hbm, 0, lpInfoHeader->biHeight, m_pCurBits, lpInfo, DIB_RGB_COLORS);<br/>
<br/>
// Move the Image from the 8 Bit Color DIB Bitmap Data from HBITMAP hbm into our PictureBox<br/>
mOurPictureBox.SetBitmap(hbm);<br/>
---<br/>
<br/>
My question is: How can the 8 bit Color DIB Bitmap Image that now exists in the HBITMAP variable hbm be converted into a 24 bit Color DIB Bitmap in memory to another HBITMAP without having to write the data to the hard drive?<br/>
<br/>
Im still learning a lot in C++, so an actual code example would be very helpful to understand how to get this done properly using standard calls without relying on wrapper classes and 3rd party libraries.<br/>
<br/>
Thanks in advance for any helpful hints,<br/>
Bill New<hr class="sig I am a Christian that believes that the Bible is true.
View the full article
<br/>
Code Fragment: (Assume all the variables below are properly typed and properly initialized!)<br/>
---<br/>
// mOurPictureBox contains a Dummy image at the same size as the image that will be replacing it below!<br/>
.<br/>
.<br/>
.<br/>
CDC* pdc = mOurPictureBox.GetDC();<br/>
<br/>
// Move our dummy image into the HBITMAP that<br/>
// we will use to place the Generated at Runtime Image<br/>
HBITMAP hbm = (HBITMAP) mOurPictureBox.GetBitmap();<br/>
<br/>
// Move the Generated at Runtime Image using our Device Context into our HBITMAP Object<br/>
SetDIBits(pdc->m_hDC, hbm, 0, lpInfoHeader->biHeight, m_pCurBits, lpInfo, DIB_RGB_COLORS);<br/>
<br/>
// Move the Image from the 8 Bit Color DIB Bitmap Data from HBITMAP hbm into our PictureBox<br/>
mOurPictureBox.SetBitmap(hbm);<br/>
---<br/>
<br/>
My question is: How can the 8 bit Color DIB Bitmap Image that now exists in the HBITMAP variable hbm be converted into a 24 bit Color DIB Bitmap in memory to another HBITMAP without having to write the data to the hard drive?<br/>
<br/>
Im still learning a lot in C++, so an actual code example would be very helpful to understand how to get this done properly using standard calls without relying on wrapper classes and 3rd party libraries.<br/>
<br/>
Thanks in advance for any helpful hints,<br/>
Bill New<hr class="sig I am a Christian that believes that the Bible is true.
View the full article