2009/3/9 <[email protected]>:
>> unsigned long
>> index,
>> ...
>> index=ReadBlobLSBShort(image)
>>
>> then at line 3487:
>>
>> if (signed_data == 1)
>> index-=32767;
>
> I haven't reviewed the code, but it looks as though the intent is
> to do the subtraction mod 2^16, so
>
> if (signed_data == 1)
> index = ((long)index - 32767) & 0xffff);
Ah, good point, later in the code there's
index&=mask;
Which does exactly this.
I think my problem is actually the window stuff. After masking, dcm.c has:
long
window_max,
window_min;
window_min=(long) (window_center-(window_width-1)/2.0-0.5);
window_max=(long) (window_center+(window_width-1)/2.0-0.5);
if (((long) index) <= window_min)
index=0;
else
if (((long) index) > window_max)
index=max_value;
else
index=max_value*((((long) index-window_center-0.5)/
(window_width-1))+0.5);
So for example, my file has:
pixel value: 10
window_center: 3736
window_width: 7472
after the subtract and mask I have index = 32779, which then gets
clipped to max_value by the window code, since index > window_max.
It's incorrectly comparing the unsigned colormap index to the signed
window limits.
Perhaps the correct solution is to always read a signed value from the
file and only to squash down to the unsigned 0-65535 colormap index
right at the end after all processing.
Here's a patch that changes dcm.c to do this.
John
_______________________________________________
Magick-developers mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-developers