Description of Problem: The function DispatchImage is used to export the data into an user provided buffer. When called with a buffer of floats and asked for the "I" component (grayscale), it returns all zeros. I tryed it with several different file types. When the component asked is "R", for example, it returns reasonable values. At the same time, checking the return value of DispatchImage has the opposite effect of the documentation. When called with "I" it returns '0', as if it were successfull, while when called with "R" it returns '1'. Version-Release number of selected component (if applicable): How Reproducible: Snippet of code: --- begin bug.cc #include <iostream> #include <stdio.h> #include <time.h> #include <sys/types.h> #include <string.h> namespace MagickLib { #undef PACKAGE #undef VERSION #include <magick/api.h> #undef inline // Remove possible definition from config.h #undef class } int main (int argc, char **argv) { if (argc != 2) { std::cout << argv[0] << " needs a filename as argument" << std::endl; return 1; } MagickLib::ImageInfo *image_info = CloneImageInfo((MagickLib::ImageInfo *) NULL); strcpy(image_info->filename, argv[1]); MagickLib::ExceptionInfo exception; MagickLib::Image *image = MagickLib::ReadImage(image_info,&exception); if (image == (MagickLib::Image *) NULL) { MagickLib::MagickError(exception.severity, exception.reason, exception.description); return 1; } int sx = image->columns; int sy = image->rows; float *data = new float[sx * sy]; for (int i = 0; i < sx*sy; ++i) data[i] = 0.5; // replace "I" to "R" and comment the error test to see the difference unsigned int errr = MagickLib::DispatchImage(image, 0, 0, sx, sy, "I", MagickLib::FloatPixel, (void*)data); DestroyImage(image); DestroyImageInfo(image_info); if (errr) { std::cout << "ERROR: " << errr << std::endl; return errr; } float *p = data; for (int r = 0; r < sx; ++r) for (int c = 0; c < sy; ++c) std::cout << "( " << r << ", " << c << " ) = " << *(p++) << std::endl; } --- end bug.cc Steps to Reproduce: 1. Compile the file above "bug.cc" with g++ `Magick++-config --cxxflags --cppflags --ldflags` -o bug bug.cc `Magick++-config --libs` 2. ./bug imagefile 3. edit the source code, replacing "I" for "R", compile it again and run (it should abort with an error). 4. edit the source code and comment the error test. compile and run. (it should now print the several different pixel values, if the original image was grayscale) Actual Results: Prints 0.5 for all pixels. Expected Results: Additional Information: Let me know if I'm missing anything.
This problem is still present in the rawhide version; passed upstream. Setting to NEEDINFO until I hear back from the maintainers.
This is fixed in the ImageMagick 5.4.3 beta. It'll be fixed in rawhide as soon as 5.4.3 leaves beta phase.
Fixed in 5.4.3.5-1