OK. So I can now replace one colour with another. I am now trying to make the replacement colour transparent. Say I want to replace white with red; I have the following code:
my $redmap = [0 .. 255]; my $blumap = [0 .. 255]; my $grnmap = [0 .. 255]; $blumap->[255] = 0; $grnmap->[255] = 0; $img->map(red=>$redmap, blue=>$blumap, green=>$grnmap);
This replaces all instances of (255,255,255) with (255,0,0). Now how do I make that red transparent? I thought I would need to do:
my $redmap = [0 .. 255]; my $blumap = [0 .. 255]; my $grnmap = [0 .. 255]; my $alpha = [0 .. 255]; $blumap->[255] = 0; $grnmap->[255] = 0; $alpha->[0] = 255; $img->map(red=>$redmap, blue=>$blumap, green=>$grnmap, alpha=>$alpha);
But that doesn't do anything. I like Imager for it's flexibility, but I am really getting frustrated with the documentation. Any help would be greatly appreciated.

Cheers!
Aaron


In reply to Re: Colour Replacement in a PNG by Striton_ca
in thread Colour Replacement in a PNG by Striton_ca

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.