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

Re: Replacing one colour with a different (transparent) colour (PNG)

From: Aaron Dalton (
11594@xyz.molar.is)
Date: Thu 05 Feb 2004 - 21:53:53 GMT

  • Next message: Tony Cook: "Re: Replacing one colour with a different (transparent) colour (PNG)"

    Thank you again, Tony, for your time. I implemented your code but am
    receiving the following error "Imager::transform2: Call to and with
    incorrect types" Below is the code:

    sub replaceColour
    {
            my ($img, $inred, $ingreen, $inblue, $outred, $outgreen, $outblue,
    $outalpha) = @_;

            my $out = Imager::transform2(
            {
                    channels=>4,
                    rpnexpr => 'x y getp1 !p @p red inred eq @p green ingreen eq and @p
    inblue 255 eq' .
                                    ' and outred outgreen outblue outalpha rgba @p red @p green @p blue
    255 rgba if',
                    constants =>
                    {
                            inred => $inred,
                            ingreen => $ingreen,
                            inblue => $inblue,
                            outred => $outred,
                            outgreen => $outgreen,
                            outblue => $outblue,
                            outalpha => $outalpha,
                    }
            }, $img) || die "transform2 failed: $Imager::ERRSTR\n";

            return $out;
    }

    Cheers!

    -- 
    Aaron Dalton
    http://aaron.daltons.ca
    PGPKeyID: 0x29844D7D
    



  •