Skip to content

Instantly share code, notes, and snippets.

@jasondew
Created July 9, 2010 22:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasondew/470217 to your computer and use it in GitHub Desktop.
Save jasondew/470217 to your computer and use it in GitHub Desktop.
getPixels :: Image -> IO [[Color]]
getPixels image =
do (width, height) <- imageSize image
pixelsPointer <- withImagePtr image $
\gdi -> #{peek gdImage, tpixels} gdi
columnPixelArray <- peekArray height pixelsPointer
mapM (\a -> peekArray width a) columnPixelArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment