[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Image generation



Yes, MacPerl includes the GD module, which can be used to draw gif images.
In your case, the following script should work:

#!/usr/local/bin/perl

use GD;

$input = "0001010111110101100111111";

# create a new image
$im = new GD::Image(5,5);

# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);

# make the background transparent and interlaced
$im->transparent($white);
$im->interlaced('true');

foreach $i (0..5) {
foreach $j (0..5) {
if (substr($input, ($i*5+$j), 1) eq "1") {
$im->rectangle($j,$i,$j,$i,$black);
}
}
}

# Convert the image to GIF and print it on standard output
print "Content-type: image/gif\n\n";
print $im->gif;

-----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCS d s:+ !a C++++ U*+++ P++++ L+ E-- W+++ N++ o+ K- w--- O? M++ V? PS PE-
Y-- PGP++ t+ 5 X R tv++ b+++ D I- D? G! e h! r
-----END GEEK CODE BLOCK-----

----------
>From: Ingo Bitsch <101701.343@compuserve.com>
>To: MacPerl Mailinglist <macperl@macperl.org>
>Subject: [MacPerl] Image generation
>Date: Sun, Jun 6, 1999, 12:54 PM
>

> Hi to all!
>
> I heard rumors that it is possible to use Macperl for the generation of
> images. In my special case, I want to write a CGI-script that takes
> something like "0001010111110101100111111", which is supposed to be a
> description of a matrix of 5x5 black or white pixels, and generates a gif
> image matching this description.
>
> Can anybody help me with this task or point me to a good documentation of
> this topic?
>
> Thanks,
> _Ingo

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org