By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,498 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,498 IT Pros & Developers. It's quick & easy.

GetBitmapBits and SetBitmapBits help

P: n/a
If I load a Bitmap from a file and I have Cbitmap and HBITMAP how is
possible to use GetBitmapBits and SetBitmapBits to modify the image
inside the memory?
BITMAP m_Bitmap; // Struct to hold info about the bitmap
HBITMAP m_hBitmap; // Handle of the bitmap
// Load the image
m_hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), "Image.bmp",
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (m_hBitmap == NULL)
{
MessageBox("Error loading bitmap");
//return;
}
//Get information about the bitmap..
GetObject(m_hBitmap, sizeof(m_Bitmap), &m_Bitmap); // Get info about
the bitmap
// Put the bitmap into a memory device context
CPaintDC dc(this);
//get a memory dc object
CDC dcMem;
//create a compatible dc
dcMem.CreateCompatibleDC(&dc); // Select the bitmap into the in-memory
DC
//Select the bitmap into the dc
CBitmap* pOldBitmap =
dcMem.SelectObject(CBitmap::FromHandle(m_hBitmap)) ;
............

I've tried to use GetBitmapBits and SetBitmapBits but I have a lot of
problems.
If you know a link about this question it's ok too. With a search
engine I've seen a lot of code but nothing that can solve my question.

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Geky wrote:
If I load a Bitmap from a file and I have Cbitmap and HBITMAP how is
possible to use GetBitmapBits and SetBitmapBits to modify the image
inside the memory?
BITMAP m_Bitmap; // Struct to hold info about the bitmap
HBITMAP m_hBitmap; // Handle of the bitmap
// Load the image
m_hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), "Image.bmp",
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (m_hBitmap == NULL)
{
MessageBox("Error loading bitmap");
//return;
}
//Get information about the bitmap..
GetObject(m_hBitmap, sizeof(m_Bitmap), &m_Bitmap); // Get info about
the bitmap
// Put the bitmap into a memory device context
CPaintDC dc(this);
//get a memory dc object
CDC dcMem;
//create a compatible dc
dcMem.CreateCompatibleDC(&dc); // Select the bitmap into the in-memory
DC
//Select the bitmap into the dc
CBitmap* pOldBitmap =
dcMem.SelectObject(CBitmap::FromHandle(m_hBitmap)) ;
...........

I've tried to use GetBitmapBits and SetBitmapBits but I have a lot of
problems.
If you know a link about this question it's ok too. With a search
engine I've seen a lot of code but nothing that can solve my question.


Hi,

This is a platform-specific question and is thus off-topic in this
forum. Try in a Microsoft newsgroup, and see the FAQ for what is
on-topic here:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Nov 22 '05 #2

P: n/a
Geky wrote:
If I load a Bitmap from a file and I have Cbitmap and HBITMAP how is
possible to use GetBitmapBits and SetBitmapBits to modify the image
inside the memory?
[...]


You're in a wrong newsgroup. You need 'comp.os.ms-windows.programmer'
(or any in that family). You need advice on Windows API, not on C++
language. They are two different things, you know...
Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.