Browse files

Fix renderPtr: Clear buffer before rendering

  • Loading branch information...
1 parent 5d36746 commit d4caa93f47e79ef74e3ea828f69dd77bc0a02b85 @haasn haasn committed Nov 18, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/Diagrams/Backend/Cairo/Ptr.hs
View
4 src/Diagrams/Backend/Cairo/Ptr.hs
@@ -8,7 +8,7 @@ import Diagrams.Backend.Cairo.Internal
import Foreign.ForeignPtr.Safe (ForeignPtr, newForeignPtr)
import Foreign.Marshal.Alloc (finalizerFree)
-import Foreign.Marshal.Array (mallocArray)
+import Foreign.Marshal.Array (mallocArray, pokeArray)
import Foreign.Ptr (Ptr, castPtr)
import Graphics.Rendering.Cairo ( Format (..)
@@ -32,7 +32,9 @@ renderPtr w h d = do
(_, r) = renderDia Cairo opt d
b <- mallocArray size
+ pokeArray b (replicate size 0)
withImageSurfaceForData b FormatARGB32 w h stride (`renderWith` r)
+
return (castPtr b)
-- | Like 'renderPtr' but automatically garbage collected by Haskell.

0 comments on commit d4caa93

Please sign in to comment.