How to Draw an image in Picture control using ImageMagick.

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
mbatra
Posts: 18
Joined: 2012-05-29T08:37:10-07:00
Authentication code: 13

How to Draw an image in Picture control using ImageMagick.

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
mbatra
Posts: 18
Joined: 2012-05-29T08:37:10-07:00
Authentication code: 13

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

Post 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.
mbatra
Posts: 18
Joined: 2012-05-29T08:37:10-07:00
Authentication code: 13

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

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply