Thanks.  I'm using the function as pure, and so far, so good.  Cheers,  - Conal

On 9/2/07, shelarcy <shelarcy@gmail.com > wrote:
Hi Conal,

On Wed, 29 Aug 2007 09:42:15 +0900, Conal Elliott < conal@conal.net> 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 ())
imageCreateFromPixelArray pixels
   = 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

http://darcs.haskell.org/wxhaskell/wxcore/src/Graphics/UI/WXCore/Image.hs


So I think we can use this function as a safe one.

Best Regards,

--
shelarcy <shelarcy    hotmail.co.jp>
http://page.freett.com/shelarcy/