ImageMagick Magick++ to HBITMAP using C++

posted in noaktree leaves
Published February 06, 2008
Advertisement
Here is a link to a function which converts a Magick::Image to a HBITMAP. I figure it'll be useful to anyone trying to get Magick++ Images working in MFC.

magick_to_HBITMAP.cpp

Here is the basic usage of the function:

// Get a pointer to the image control and resize it to 200 x 200
CWnd* pImageControl = m_MFCImage_Control.GetWindow(0);
pImageControl->MoveWindow(10,10,200,200,1);

// Read in the Magick::Image file and resize it to the same size as the MFCImage
m_Image.read("image.jpg");
m_Image.resize(Magick::Geometry(200,200));

// Convert it and set it
m_Bitmap = CreateBitmapFromMagick(m_MFCImage_Control.GetDC()->m_hDC, m_Image);
m_MFCImage_Control.SetBitmap(m_Bitmap);

// Don't forget to delete the HBITMAP when you're done using DeleteObject(m_Bitmap);
Previous Entry Problems != Good Sleep
Next Entry Making a game
0 likes 3 comments

Comments

Pipo DeClown
MFC? X_X
March 12, 2008 11:53 AM
Programmer16
Quote:Original post by Pipo DeClown
MFC? X_X


QFT
March 12, 2008 12:06 PM
noaktree
Yeah you know, like the MFC 9.0 that was released with Visual Studio 2008.
April 14, 2008 12:37 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement