|
Image::BMP - Bitmap parser/viewer |
Image::BMP - Bitmap parser/viewer
use Image::BMP;
# Example one:
my $img = new Image::BMP(
file => 'some.bmp',
debug => 1,
);
$img->view_ascii;
# Example two:
my $img2 = new Image::BMP;
$img2->open_file('another.bmp');
my $color = $img2->xy(100,100); # Get pixel at 100,100
my ($r,$g,$b) = $img2->xy_rgb(100,200);
Image::BMP objects can parse and even ascii view bitmaps of the
.BMP format. It can read most of the common forms of this format.
It can be used to:
my $img = new Image::BMP(file => 'some.bmp');
print "Resolution: $img->{Width} x $img->{Height}\n";
(See C<SYNOPSIS> example one)
(See C<SYNOPSIS> example two)
(See C<ADD_PIXEL> below)
It does not currently write bmap data, simply because I didn't have a use for that yet. Convince me and I'll add it.
The following data/keys are read when opening an image:
FileSize, DataOffset, HeaderSize, Width, Height,
Planes, BitCount, ColorBytes, Compression,
(compression enum: RGB, RLE8, RLE4, BITFIELDS)
ImageSize, XpixelsPerM, YpixelsPerM, ColorsUsed, ColorsImportant
Image::BMP object:
$img->open_pipe("convert some.jpg bmp:-");
load if necessary)
load if necessary)
load if necessary)
load if necessary)
debug setting. Values are:
Generally only debug=0 or =1 are useful.
remember_image setting. See ADD_PIXEL below.
Instead of having the object read the image into memory (or in addition to), you can process all the image data yourself by supplying a callback function:
sub my_add {
my ($img,$x,$y,$r,$g,$b) = @_;
print "add pixel $x,$y = $r,$g,$b\n";
}
my $img = new Image::BMP(file => 'some.bmp', add_pixel = \&my_add);
$img->load;
It may be useful to note that most bitmaps are read from left to right and bottom to top (x from 0 to width, y from height to 0), though the compression can skip values.
If you supply an add_pixel callback then load will not
store the image data for efficiency. This means, however, that
view_ascii, xy and xy_rgb will not work. You can use
add_pixel and still save the image in memory by setting
remember_image.
Copyright 2004 <a href='http://GetDave.com/'>David Ljung Madison</a>. All rights reserved. See: <a href='http://MarginalHacks.com/'>MarginalHacks.com</a>
|
Image::BMP - Bitmap parser/viewer |