Page 1 of 1

How to Draw an image in Picture control using ImageMagick.

Posted: 2012-05-30T23:12:49-07:00
by mbatra
Hi,

I have a MFC dialog based application with a picture control on it. I want to draw an image in the picture control using ImageMagick. Can anybody give a sample code for the same.



Regards,
mbatra

Re: How to Draw an image in Picture control using ImageMagic

Posted: 2012-05-31T09:39:52-07:00
by fmw42
mbatra wrote:Hi,

I have a MFC dialog based application with a picture control on it. I want to draw an image in the picture control using ImageMagick. Can anybody give a sample code for the same.



Regards,
mbatra
Can you elaborate or provide some examples. I for one do not have clue what MFC dialog based application is nor what a picture control is.

Re: How to Draw an image in Picture control using ImageMagic

Posted: 2012-05-31T22:01:16-07:00
by mbatra
Hi,

I created an MFC dialog based application. On the dialog, I am using a Picture control (MFC's picture control) in which we can draw an image using its device context handle. Now I am using ImageMagick (Magick++) library to Flip/rotate an image. Please find below the sample code.
try
{
string srcdir("");
if(getenv("SRCDIR") != 0)
srcdir = getenv("SRCDIR");

// Read images into STL list
list<Image> imageList;
//readImages( &imageList, srcdir + "smile_anim.miff" );
readImages( &imageList, srcdir + "t-shirt.png" );

// Flip images
for_each( imageList.begin(), imageList.end(), flipImage() );
//for_each( imageList.begin(), imageList.end(), cropImage(Geometry(220,220,500,200)) );

// Create a morphed version, adding three frames between each existing frame.
list<Image> morphed;
morphImages( &morphed, imageList.begin(), imageList.end(), 1 );

// Write out images
writeImages( morphed.begin(), morphed.end(), "flip_image11.png" );
}
catch( exception &error_ )
{
//cout << "Caught exception: " << error_.what() << endl;
}

This will read the image from the specified directory, provide the feature and then save it into the same dir. Now I want to Draw/Display that output image in the MFC picture control on the dialog using ImageMagick (Magick++) library functions.
Please let me know if u want me to elaborate this in more detail.

Also when I use read function of Image class to read an image from the dir, it throws an error in std::basic_string (Elem *) function of xstring.h.

Please hellp me if I can use read , write , draw functions of Image class.


Thanx & Regards,
mbatra.

Re: How to Draw an image in Picture control using ImageMagic

Posted: 2012-06-05T04:42:27-07:00
by mbatra
fmw42 wrote:
mbatra wrote:Hi,

I have a MFC dialog based application with a picture control on it. I want to draw an image in the picture control using ImageMagick. Can anybody give a sample code for the same.



Regards,
mbatra
Can you elaborate or provide some examples. I for one do not have clue what MFC dialog based application is nor what a picture control is.


Hi,

I created an MFC dialog based application. On the dialog, I am using a Picture control (MFC's picture control) in which we can draw an image using its device context handle. Now I am using ImageMagick (Magick++) library to Flip/rotate an image. Please find below the sample code.
try
{
string srcdir("");
if(getenv("SRCDIR") != 0)
srcdir = getenv("SRCDIR");

// Read images into STL list
list<Image> imageList;
//readImages( &imageList, srcdir + "smile_anim.miff" );
readImages( &imageList, srcdir + "t-shirt.png" );

// Flip images
for_each( imageList.begin(), imageList.end(), flipImage() );
//for_each( imageList.begin(), imageList.end(), cropImage(Geometry(220,220,500,200)) );

// Create a morphed version, adding three frames between each existing frame.
list<Image> morphed;
morphImages( &morphed, imageList.begin(), imageList.end(), 1 );

// Write out images
writeImages( morphed.begin(), morphed.end(), "flip_image11.png" );
}
catch( exception &error_ )
{
//cout << "Caught exception: " << error_.what() << endl;
}

This will read the image from the specified directory, provide the feature and then save it into the same dir. Now I want to Draw/Display that output image in the MFC picture control on the dialog using ImageMagick (Magick++) library functions.
Please let me know if u want me to elaborate this in more detail.

Also when I use read function of Image class to read an image from the dir, it throws an error in std::basic_string (Elem *) function of xstring.h.

Please hellp me if I can use read , write , draw functions of Image class.


Thanx & Regards,
mbatra.

Re: How to Draw an image in Picture control using ImageMagic

Posted: 2012-06-19T17:10:49-07:00
by anthony
Everything IM waise appears fine. But I doubt anyone here knows much about MFC.
I can't even see in the code how an image is passed to MFC!

I suggest you look for a MFC forum, and try to keep the example as simple as possible (no flips or other image manipulation). Also check what format MFC expects the image in, as I an certain the pointer to the image in IM is not the same (IM image pointer is not a pointer to raw image data but IM stored image meta-data).