Thanks. I'm using the function as pure, and so far, so good. Cheers, - Conal
On Wed, 29 Aug 2007 09:42:15 +0900, Conal Elliott < firstname.lastname@example.org> wrote:
> Is there any reason for imageCreateFromPixelArray to be in IO? I want to
> use it as a pure function (via unsafePerformIO), and I'm wondering if there
> are any gotchas. - Conal
I think it's just implementation reason.
imageCreateFromPixelArray create pixelBuffer and set pixelBuffer
color interanally, and then create image by pixelBuffer.
imageCreateFromPixelArray :: Array Point Color -> IO (Image ())
= let (Point x y) = snd (bounds pixels)
in imageCreateFromPixels (sz (x+1) (y+1)) (elems pixels)
imageCreateFromPixels :: Size -> [Color] -> IO (Image ())
imageCreateFromPixels size colors
= do pb <- pixelBufferCreate size
pixelBufferSetPixels pb colors
imageCreateFromPixelBuffer pb -- image deletes pixel buffer
So I think we can use this function as a safe one.
shelarcy <shelarcy hotmail.co.jp>