SWF-Builder

 view release on metacpan or  search on metacpan

lib/SWF/Builder/Character/Bitmap.pm  view on Meta::CPAN

use Compress::Zlib;

@SWF::Builder::Character::Bitmap::Lossless::ISA = qw/ SWF::Builder::Character::Bitmap::Def /;

sub new {
    my ($class, $obj, $type) = @_;

    unless (defined($type)) {
	if (UNIVERSAL::isa($obj, 'GD')) {
	    $type = 'GD';
	} elsif (UNIVERSAL::isa($obj, 'Image::Magick')) {
	    $type = 'ImageMagick';
	} elsif (not ref($obj)) {
	    if ($obj =~/\.png$/i or $obj =~/\.jpe?g$/i or $obj =~ /\.xpm$/i or $obj =~ /\.gd2$/i) {
		$type = 'GD';
	    } else {
		$type = 'ImageMagick';
	    }
	} else {
	    croak "Unknown bitmap object";
	}

lib/SWF/Builder/Character/Bitmap.pm  view on Meta::CPAN

Acceptable types are as follows:

=over 4

=item GD

takes a GD::Image object.

=item ImageMagick

takes an Image::Magick object.

=item Custom

takes an array reference of [ $width, $height, $colors, $is_alpha, \&pixsub ].
$width and $height are the width and height of the bitmap.
$colors is a total number of colors of the bitmap. If it is under 256,
the bitmap is converted to colormapped image, otherwise 24-bit full color.
$is_alpha is a flag whether the bitmap has an alpha data.
&pixsub is a subroutine, which takes pixel coordinates ($x, $y) and returns
an array of the color data of the pixel, ($r, $g, $b, $a).

lib/SWF/Builder/Character/Bitmap/Lossless/ImageMagick.pm  view on Meta::CPAN

package SWF::Builder::Character::Bitmap::Lossless::ImageMagick;

use strict;
use Image::Magick;

our @ISA = ('SWF::Builder::Character::Bitmap::Lossless');
our $VERSION = '0.02';

sub new {
    my ($class, $image) = @_;

    unless (ref($image)) {
	my $file = $image;
	$image = Image::Magick->new;
	$image->Read($file);
    }
    bless {
	_width  => $image->Get('width'),
	_height => $image->Get('height'),
	_colors => $image->Get('colors'),
	_is_alpha => $image->Get('matte'),
	_pixsub => sub {
	    my ($x, $y) = @_;
	    my  @rgba = map{$_ & 255} split /,/, $image->Get("pixel[$x,$y]");



( run in 0.354 second using v1.01-cache-2.11-cpan-beeb90c9504 )