[Haskell-cafe] Writing a pnm file

CK Kashyap ck_kashyap at yahoo.com
Sun Aug 2 11:00:56 EDT 2009


Hi,
Now that I've understood how to generate raster points of a line in Haskell - the next thing I want to do is generate a pnm file with it. I've done it in perl as of now. In perl, I can have a scalar variable $x contain a string of 256*256*3 bytes (for 24-bit 256x256 image) and set pixels using substr on LHS. I was wondering how I could do something similar in Haskell?

sub setPixel{
my($x,$y,$red,$green,$blue)=@_;
my$pixel=pack "CCC",$red,$green,$blue;
my$offset=$WIDTH*$y*3 + $x*3;
substr($image,$offset,3) = $pixel;
}

Regards,
Kashyap



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090802/ee5bb01d/attachment.html


More information about the Haskell-Cafe mailing list