NAME

SWF::Builder::Character::Bitmap - SWF Bitmap object

SYNOPSIS

    my $jpeg = $mc->new_jpeg( 'picture.jpg' );
    $jpeg->place;

    use GD;
    $gd = GD::Image->newFromPng( 'tile.png' );
    my $bm = $mc->new_bitmap( $gd, 'GD' );
    my $shape = $mc->new_shape
                ->fillstyle($bm, 'tiled', $bm->matrix)
		->box(0, 0, 100, 100);

DESCRIPTION

SWF supports JPEG and lossless bitmaps.

$jpg_bm = $mc->new_jpeg( JPEGFile => $filename / JPEGData => $jpegdata, AlphaFile => $filename / AlphaData => $alphadata / Alpha => $alpha )
$jpg_bm = $mc->new_jpeg( $filename )

returns a new JPEG bitmap. It can take named parameters as follows:

JPEGFile / JPEGData

set a JPEG Data from a file and a binary data string, respectively.

AlphaFile / AlphaData / Alpha

set an alpha (transparency) data from a file, a binary data string, and a single byte, respectively. The alpha data is width x height length string of byte, 0(transparent) to 255(opaque). A single byte Alpha is expanded into the proper size.

When you give a single parameter, it is regarded as the JPEG file name. Same as JPEGFile => $filename.

$jpg_bm->JPEGData/AlphaData/Alpha( $data )

set a JPEG/Alpha data.

$jpg_bm->load_jpeg/load_alpha( $filename )

load a JPEG/alpha data file.

$ll_bm = $mc->new_bitmap( $obj [, $type] )

returns a new lossless bitmap converted from a $type of $obj. If $type is omitted, it is guessed. If $obj is not an object, it is treated as a file name.

Acceptable types are as follows:

GD

takes a GD::Image object.

ImageMagick

takes an Image::Magick object.

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).

$bm->width

returns the bitmap width.

$bm->hegiht

returns the bitmap height.

$bm->get_bbox

returns the bounding box of the bitmap, (0, 0, width, height).

$bm->matrix

returns a bitmap transformation matrix.

$bm_i = $bm->place( ... )

returns the display instance of the bitmap (to be exact, returns the instance of a box shape which filled with the bitmap). See SWF::Builder.

COPYRIGHT

Copyright 2003 Yasuhiro Sasama (ySas), <ysas@nmt.ne.jp>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.