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
How to Draw an image in Picture control using ImageMagick.
- 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
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 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
Re: How to Draw an image in Picture control using ImageMagic
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.
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
fmw42 wrote: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 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
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.
- 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
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).
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/
https://imagemagick.org/Usage/