I was hoping someone could give me an idea on the best method for converting a Magick::Image to a wxImage to be then drawn on screen using a paintDC. I have had a long scan online but haven't yet found a simple method that works yet, I've concluded its something I'm definitely missing in my code.
At the moment I have a very simple wxControl that I hope to have display the converted image. Here is the constructor:
Code: Select all
Canvas::Canvas(wxWindow* parent) :
wxControl(parent, wxID_ANY, wxDefaultPosition, wxSize(parent->GetSize().GetWidth(),parent->GetSize().GetHeight()))
{
m_imageBufferSize = GetSize().GetHeight() * GetSize().GetWidth() * 4;
m_imageBuffer = new unsigned char[m_imageBufferSize];
m_magImage = new Magick::Image("myImage.jpg");
m_magImage->depth( 8 );
m_magImage->writePixels( Magick::RGBQuantum, m_imageBuffer );
GetEventHandler()->Connect(wxEVT_PAINT, wxPaintEventHandler (Canvas::on_paint),0,this);
}
Code: Select all
void Canvas::on_paint(wxPaintEvent& event)
{
wxImage tempImage(GetSize().GetWidth(), GetSize().GetHeight(), m_imageBuffer, true);
wxBitmap tempBmp(tempImage);
wxBufferedPaintDC dc(this, tempBmp);
}
Many Thanks!
-SL