The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PCX::Loader - Loads 320x200 8-bit PCX-format graphics.

SYNOPSIS

        my $pcx = PCX::Loader->new('face.pcx');

METHODS

new($filename);

Constructor. Loades PCX file into class.

This is a treat... this routine will load a PCX-format file (yah, I know ... ancient format ... but it is the only one I could find specs for to write it in Perl. If anyone can get specs for any other formats, or could write a loader for them, I would be very grateful!) Anyways, a PCX-format file that is exactly 320x200 with 8 bits per pixel, with pure Perl. It returns a blessed refrence to a PCX::Loader object.

The object will have the following attributes:

$pcx->{image}

This is an array refrence to the entire image. The array containes exactly 64000 elements, each element contains a number corresponding into an index of the palette array, details below.

$pcx->{palette}

This is an array ref to an AoH (array of hashes). Each element has the following three keys:

        $pcx->{palette}->[0]->{red};
        $pcx->{palette}->[0]->{green};
        $pcx->{palette}->[0]->{blue};

Each is in the range of 0..63, corresponding to their named color component.

$pcx->get_block($array_ref);

Returns a rectangular block defined by an array ref in the form of:

        [$left,$top,$right,$bottom]

The return value is an array ref.

These must be in the range of 0..319 for $left and $right, and the range of 0..199 for $top and $bottom. The block is returned as an array ref with horizontal lines in sequental order. I.e. to get a pixel from [2,5] in the block, and $left-$right was 20, then the element in the array ref containing the contents of coordinates [2,5] would be found by [5*20+2] ($y*$width+$x).

        print $pcx->get_block(0,0,20,50)->[5*20+2];

This would print the contents of the element at block coords [2,5].

$pcx->get($x,$y);

Returns the value of pixel at image coordinates $x,$y. $x must be in the range of 0..319 and $y must be in the range of 0..199.

$pcx->rgb($index);

Returns a 3-element array (not array ref) with each element corresponding to the red, green, or blue color components, respecitvely.

$pcx->avg($index);

Returns the mean value of the red, green, and blue values at the palette index in $index.

BUGS

Please submit bugs to the CPAN bug tracker or the Github repository.

AUTHOR

Josiah Bryan <jdb@wcoil.com>, Alexander Becker <asb@cpan.org>

Copyright (c) 2000 Josiah Bryan, 2017 Alexander Becker. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The PCX::Loader module is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.