Perl: recomended method to plot(x,y) pixels to a monochrome bitmap

0 votes
asked Jul 25, 2009 by lexu

For a home project I need to plot (x,y) coordinates onto a 400x400 black and white-bitmap.

What perl module would you recoment and what image format (GIF?, PNG? other?) would be easiest to handle on OS X, Windows, Linux?

EDIT My solution, based on GD, as recomended by Brian Agnew

use strict;
use warnings;
use GD;
my $BitMap = GD::Image->new(400,400);

my $white = $BitMap->colorAllocate(255,255,255);
my $black = $BitMap->colorAllocate(0,0,0);       

# Frame the BitMap
# Transparent image, white background color

# plot some, just to show it works #
for my $x (0..100) {
   for my $y (0 .. 100) {

# write png-format to file
open my $fh,">","test.png" or die "$!";
binmode $fh;
print $fh $BitMap->png;

1 Answer

0 votes
answered Jul 25, 2009 by brian-agnew

Have a look at the GD module (which interfaces to the GD library). It makes creating graphics pretty trivial and has a wide range of output formats, including PNG and GIF.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter