I'm just starting with the C++ API for ImageMagick. I'm having no trouble working with existing images, but can't for the life of me manage to create an image from scratch and get it to work the way I expect. Here's my test case:

#include <Magick++.h>

using namespace Magick;

main(int argc, char *argv[])
{
   Geometry size(100, 100);
   ColorRGB color("red");
   Image image(size, color);
   int width  = size.width();
   int height = size.height();

   image.modifyImage();
   PixelPacket *pixels = image.getPixels(0, 0, width, height);
   ColorRGB c("green");
   for (int i = 0; i < width * height; i++) {
       *(pixels+i) = c;
   }
   image.syncPixels();
   image.modifyImage();
   image.display();
   image.write("foo.jpg");
   image.read("foo.jpg");
   image.display();

   return(0);
}

The first display() displays a red image. The second display() displays the expected green image.

What am I doing wrong?

Fedora Core 8, ImageMagick 6.3.5.9

roland

--
                       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
[EMAIL PROTECTED]                            6818 Madeline Court
[EMAIL PROTECTED]                           Brooklyn, NY 11220

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to