Bug 58080 - DispatchImage function return all zeros when used with "I" and FloatPixel
Summary: DispatchImage function return all zeros when used with "I" and FloatPixel
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: ImageMagick
Version: 7.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-01-08 02:20 UTC by Siome Goldenstein
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-01-22 21:48:08 UTC
Embargoed:


Attachments (Terms of Use)

Description Siome Goldenstein 2002-01-08 02:20:45 UTC
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.

Comment 1 Bernhard Rosenkraenzer 2002-01-17 13:13:32 UTC
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 21:48:03 UTC
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 11:07:33 UTC
Fixed in 5.4.3.5-1


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