 -- | Convert an image to from arbitrary bit depth into 32 bit, floating point, image.
 --   This conversion does preserve the color space.
 -- Note: this function is named unsafe because it will lose information
--- from the image. 
+-- from the image.
 unsafeImageTo32F :: Image c d -> Image c D32
 unsafeImageTo32F img = unsafePerformIO $ withGenImage img $ \image ->
                 creatingImage

                    Mutable <$> creatingImage ({#call cvCloneImage #} image)

fromMutable :: MutableImage a b -> IO (Image a b)
fromMutable (Mutable img) = cloneImage img 

-- | Create a copy of a non-types image
cloneBareImage :: BareImage -> IO BareImage


withRawImageData :: Image c d -> (Int -> Ptr Word8 -> IO a) -> IO a
withRawImageData (S i) op = withBareImage i $ \pp-> do
                             d  <- {#get IplImage->imageData#} pp
                             wd <- {#get IplImage->widthStep#} pp
                             op (fromIntegral wd) (castPtr d)

