Author image Alexander Becker


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


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



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:


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.


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


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


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


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


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.


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


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


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


Josiah Bryan <>, Alexander Becker <>

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.