On 18 January 2009 18:19:06 you wrote:
> I am willing to transmit this bug report to upstream, but unfortunatly I am
> not really a perl hacker.
>
> therefore could you please summarize this bug for us poor mortal soul :)
> Including may be a test case :)

Hello.

Test case is very simple and obvious when you know what is wrong.

        my $image = new Image::Magick;
        $iImage->Read("template.png");
# template.png is just any RGB image you want to use
        $image->SetPixel(channel => "Blue", x => 10, y  => 10, color   => [1]);
        $image->Write("out_image.png");

this code must put a blue pixel at (10,10) location and write a resulting 
image. But it doesn't. Actually, if I do:
        $image->SetPixel(channel => "RGB", x => 10, y  => 10, color   => 
[1,1,1]);
it will put a yellow(!) point instead of white! I need to put one extra 
element into the array of colors to have this working as expected. The 
reason: in the file Magick.xs in function SetPixel av_len() function used as 
if it returns length of an array but actually it returns highest index. In 
this code:

        if (((channel & RedChannel) != 0) && (i < av_len(av)))
          {
            q->red=RoundToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
            i++;
          }
        if (((channel & GreenChannel) != 0) && (i < av_len(av)))
          {
            q->green=RoundToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
            i++;
          }
        if (((channel & BlueChannel) != 0) && (i < av_len(av)))
          {
            q->blue=RoundToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
            i++;
          }
        if ((((channel & IndexChannel) != 0) &&
            (image->colorspace == CMYKColorspace)) && (i < av_len(av)))
          {
            *indexes=RoundToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
            i++;
          }
        if (((channel & OpacityChannel) != 0) && (i < av_len(av)))
          {
            q->opacity=RoundToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
            i++;
          }

av_len must be used as (i <= av_len(av)).
-- 
Anton Petrusevich



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to