Hi, I'm using the below perl code fragment to load many transparent png files into a single swf object. I think I must be mucking up the alpha level in my conversion somewhere, because the transparencies are being lost. A little help please, am I making the mistake in perl, imagemagik or swf formatting ?
my $image = Image::Magick->new; $image->Read("image_piece03.png"); my $width = 16; my $height = 16; my $lossless; $lossless = SWF::Element::Tag::DefineBitsLossless->new( CharacterID => 1, BitmapFormat => 5, BitmapWidth => $width, BitmapHeight => $height, ); my $d = deflateInit() or die "Can't open zlib stream."; for(my $y = 0; $y<$height; $y++) { for(my $x = 0; $x<$width; $x++) { my @rgba = split /,/, $image->Get("pixel[$x,$y]"); $rgba[3] = 255-$rgba[3]; @rgba=@rgba[3,0..2]; my ($output, $status) = $d->deflate(pack('CCCC',@rgba)); # 4 b +ytes per pixel. die "Compress error." unless $status == Z_OK; $lossless->ZlibBitmapData->add($output); } } my ($output, $status) = $d->flush(); die "Compress error." unless $status == Z_OK; $lossless->ZlibBitmapData->add($output); $lossless->pack($new);

In reply to Perserving transparency png into swf by Anonymous Monk

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.