Perl: recomended method to plot(x,y) pixels to a monochrome bitmap -
I should plot for home project (x, y) coordinates on 400x400 black and white-bitmap.
What Pearl module would you recoment and what would be easy to handle on image format (GIF ?, PNG? Other?) OS X, Windows, Linux?
Edit My solution is based on GD, as recommended by Brian Agnew
Strict ; Use warnings; Use GD; My $ Bitmap = GD :: image- & gt; New (400,400); My $ white = $ bitmap- & gt; Color alarms (255,255,255); My $ black = $ bitmap- & gt; Color alarms (0,0,0); # Frame bitmap $ bitmap- & gt; Rectangle (0, 0, 39, 9, 39, $ black); # Transparent image, white background color $ bitmap- & gt; Transparent ($ white); # For some conspiracy, to show that my $ x (0..100) {my $ y (0 .. 100) {$ Bitmap- & gt; Set pixel (250 + 100 * sin ($ x) - $ for y, 150 + 125 * because ($ x) + $ y, black $); }} Open my $ FH to open the file # $ PH, "& gt;", "test.png" or "$!" Die; Binmode $ fh; Print $ FH $ Bitmap- & gt; Png; Close ($ FH); Take a look at
(which is the interface). It makes the graphics very trivial and has many output formats including PNG and GIF.
Comments
Post a Comment