Advertisement
jckuri

RedPNG.hs

Jul 5th, 2014
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- RedPNG.hs
  2. import qualified Codec.Picture as CP
  3. import qualified Data.Vector.Storable as DV  
  4.    
  5. writeRedPNG filename (width,height) =
  6.  let
  7.   imageVector = DV.generate (width * 3 * height) getPixel
  8.   getPixel i =
  9.    case i `mod` 3 of
  10.     0 -> 255
  11.     1 -> 0
  12.     2 -> 0
  13.   image = CP.Image width height imageVector
  14.   imageRGB8 = CP.ImageRGB8 image
  15.  in CP.writeDynamicPng filename imageRGB8
  16.  
  17. main = writeRedPNG "red.png" (200,50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement