Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perserving transparency png into swf
by almut (Canon) on Dec 13, 2007 at 09:28 UTC | |
by Anonymous Monk on Dec 13, 2007 at 22:39 UTC |