Bug 58080 - DispatchImage function return all zeros when used with "I" and FloatPixel
DispatchImage function return all zeros when used with "I" and FloatPixel
Product: Red Hat Linux
Classification: Retired
Component: ImageMagick (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
Depends On:
  Show dependency treegraph
Reported: 2002-01-07 21:20 EST by Siome Goldenstein
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-01-22 16:48:08 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Siome Goldenstein 2002-01-07 21:20:45 EST
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

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)
    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);

  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.
Comment 1 Bernhard Rosenkraenzer 2002-01-17 08:13:32 EST
This problem is still present in the rawhide version; passed upstream.
Setting to NEEDINFO until I hear back from the maintainers.
Comment 2 Bernhard Rosenkraenzer 2002-01-22 16:48:03 EST
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.
Comment 3 Bernhard Rosenkraenzer 2002-02-22 06:07:33 EST
Fixed in

Note You need to log in before you can comment on or make changes to this bug.