Image::Magick::Iterator::PPM - read PPM images


Image-Magick-Iterator documentation Contained in the Image-Magick-Iterator distribution.

Index


Code Index:

NAME

Top

Image::Magick::Iterator::PPM - read PPM images

DESCRIPTION

Top

Image::Magick::Iterator delegates to this class for low level image byte read()s. Don't use this class directly.

FEEDBACK

Top

See Image::Magick::Iterator.

AUTHOR

Top

Allen Day <allenday@ucla.edu>

COPYRIGHT AND LICENSE

Top

APPENDIX

Top

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a '_'. Methods are in alphabetical order for the most part.

read_image()

Usage
  $obj->read_image($filehandle);

Function

reads an image from a filehandle.

Returns

raw data for one PPM image. this is complete, including header and pixels.

Arguments

a filehandle reference


Image-Magick-Iterator documentation Contained in the Image-Magick-Iterator distribution.

# Let the code begin...


package Image::Magick::Iterator::PPM;
use strict;
use base qw();
use Image::PBMlib;
our $VERSION = '0.01';

sub read_image {
  my $pack = shift;
  my $handle = shift;

  my $bytes_per_pixel = 3;

  my $header = readppmheader($handle);

  return undef unless defined($header->{width}) and defined($header->{height});

  my $buf;

  my $rc = read($handle,$buf, $header->{width} * $header->{height} * $bytes_per_pixel);

  return undef unless( $rc == ($header->{width} * $header->{height}) * $bytes_per_pixel);
  return makeppmheader($header).$buf;
}

1;