(none) imager-devel
/ help / lists / applications / search /

Re: Alpha channel gradient bug?

From: Tony Cook (
Date: Sun 25 Nov 2001 - 03:16:04 UTC

  • Next message: Greg Krieser: "Re: imager speed versus shell commands"

    On Sat, 24 Nov 2001, Mike Depot wrote:

    > I want to make a gradient on an alpha channel so I can later use it as a
    > rubthrough on a another source image to create a fadeout effect along the
    > gradient. In trying to do this I found something that I don't understand.
    > Why is it that if I create a gradient on a 2 channel (greyscale with alpha?)
    > image, that I get a different alpha channel than if I create a gradient on a
    > 4 channel image (RGB with alpha?) To illustrate this, run the test program
    > below, and look at the four resulting image files. image2.png and
    > image4.png have the same appearance, but when you look at the extracted
    > alpha channels, they are different.

    image2 and image4 looked different here in The GIMP - image2 shows the
    background at the left of the image, while image4 is opaque.

    > Shouldn't both alpha channels be the same?
    > If so, which is correct, the gradient or the all white?
    > If the all white is correct, how should I go about making a gradient on an
    > alpha channel?

    Both are producing the correct result.

     my $color_white = Imager::Color->new("#FFFFFF");
     my $color_black = Imager::Color->new("#000000");

    should be:
     my $color_white = Imager::Color->new("#FFFFFFFF");
     my $color_black = Imager::Color->new("#00000000");

    When you create a color with Imager::Color the alpha channel defaults to

    For the 'none' combine type the channels in the gradient color simply
    replace the corresponding colors in the image. In this case the alpha
    channel for 4 channel image is 255 at both ends of the range, so the alpha
    is 255 for the whole fill.

    > $im2->filter(
    > type => "fountain",
    > xa => 0, ya => 0,
    > xb => $width-1, yb => 0,
    > ftype => "linear",
    > repeat => "none",
    > combine => "none",
    > super_sample => "circle",
    > ssample_param => 4,
    > segments => $segs,
    > );

    (why supply so many of the defaults?)