GetBitmapBits and SetBitmapBits help

G

Geky

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.
 
M

mlimber

Geky said:
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-lite/how-to-post.html#faq-5.9

Cheers! --M
 
V

Victor Bazarov

Geky said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top