Simple Read/Writing with Magick++ 6.7.8 stopped working?

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
anjos
Posts: 1
Joined: 2012-07-05T04:14:58-07:00
Authentication code: 13

Simple Read/Writing with Magick++ 6.7.8 stopped working?

Post by anjos »

I guess something has changed in the latest(s) releases of ImageMagick. The following program does not work as intented with Magick++ 6.7.8 (at least) anymore:

Code: Select all

#include <iostream>
#include <ImageMagick/Magick++.h>

int main(int argc, char** argv) {

  if (argc != 2) {
    std::cerr << "usage: " << argv[0] << " <filename>" << std::endl;
    exit(1);
  }

  char test_image[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

  // save sample image
  Magick::Image image;
  image.size(Magick::Geometry(4, 6));
  //image.colorSpace(Magick::GRAYColorspace);
  image.read(4, 3, "I", Magick::CharPixel, test_image);
  image.depth(8*sizeof(char));
  image.write(argv[1]);

  // reload sample image
  Magick::Image reloaded(argv[1]);
  char test_reload[24];
  reloaded.write(0, 0, 4, 3, "I", Magick::CharPixel, test_reload);

  std::cout << "original x reloaded:" << std::endl;
  for (int i=0; i<12; ++i) {
    std::cout << "  " << (int)test_image[i] << ", "
      << (int)test_reload[i] << std::endl;
  }

  exit(0);
}
The reloaded pixels give very different values than the original ones. Do I need to do something else to get this example working? Or is it just a nasty bug.

To compile this app, I use ImageMagick 6.7.8 on OSX with MacPorts, but I think this is probably platform agnostic:

Code: Select all

g++ -g -I /opt/local/include -I /opt/local/include/ImageMagick -L /opt/local/lib -lMagick++ test.cc
The output I get:

Code: Select all

original x reloaded:
  1, 0
  2, 0
  3, 0
  4, 0
  5, 0
  6, 0
  7, 1
  8, 1
  9, 1
  10, 1
  11, 1
  12, 1
Where I was expecting to get a matching output - as before.

Thanks for any hints, Andre
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Simple Read/Writing with Magick++ 6.7.8 stopped working?

Post by magick »

We can reproduce the problem you posted and have a patch. Look for it in ImageMagick 6.7.8-2 Beta by sometime tomorrow. Thanks.
Post Reply