Sign in to follow this  
  • entries
    149
  • comments
    510
  • views
    94518

ImageMagick Magick++ to HBITMAP using C++

Sign in to follow this  

814 views

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);
Sign in to follow this  


3 Comments


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now