Jump to content
Sign in to follow this  
  • entries
    149
  • comments
    510
  • views
    95068

ImageMagick Magick++ to HBITMAP using C++

Sign in to follow this  
noaktree

953 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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!