 tileImages image1 image2 (x,y) = unsafePerformIO $
                                withImage image1 $ \i1 ->
                                 withImage image2 $ \i2 ->
-                                 creatingImage ({#call simpleMergeImages#} 
+                                 creatingImage ({#call simpleMergeImages#}
                                                 i1 i2 x y)
--- | Blit image2 onto image1. 
+-- | Blit image2 onto image1.
 blitFix = blit
-blit image1 image2 (x,y) 
-    | badSizes  = error $ "Bad blit sizes: " ++ show [(w1,h1),(w2,h2)]++"<-"++show (x,y) 
+blit image1 image2 (x,y)
+    | badSizes  = error $ "Bad blit sizes: " ++ show [(w1,h1),(w2,h2)]++"<-"++show (x,y)
     | otherwise = withImage image1 $ \i1 ->
                    withImage image2 $ \i2 ->
                     ({#call plainBlit#} i1 i2 (fromIntegral y) (fromIntegral x))
-    where 
+    where
      ((w1,h1),(w2,h2)) = (getSize image1,getSize image2)
      badSizes = x+w2>w1 || y+h2>h1 || x<0 || y<0
 

  :: Image channels depth
     -> (Image channels depth -> IO a)
     -> IO a
withCloneValue img fun = do 
                result <- cloneImage img
                r <- fun result
                return r

unsafeImageTo32F :: Image c d -> Image c D32
unsafeImageTo32F img = unsafePerformIO $ withGenImage img $ \image -> 
                creatingImage 
                 ({#call ensure32F #} image)

unsafeImageTo8Bit :: Image cspace a -> Image cspace D8
unsafeImageTo8Bit img = unsafePerformIO $ withGenImage img $ \image -> 
                creatingImage 
                 ({#call ensure8U #} image)

imageTo32F img = withGenBareImage img $ \image -> 
                creatingBareImage 
                 ({#call ensure32F #} image)

imageTo8Bit img = withGenBareImage img $ \image -> 
                creatingBareImage 
                 ({#call ensure8U #} image)
#c
enum ImageDepth {
     Depth32F = IPL_DEPTH_32F,
     Depth64F = IPL_DEPTH_64F,
     Depth8U  = IPL_DEPTH_8U, 
     Depth8S  = IPL_DEPTH_8S, 
     Depth16U  = IPL_DEPTH_16U, 
     Depth16S  = IPL_DEPTH_16S,
     Depth32S  = IPL_DEPTH_32S
     };
#endc
 
{#enum ImageDepth {}#}

deriving instance Show ImageDepth


-- #define FGET(img,x,y) (((float *)((img)->imageData + (y)*(img)->widthStep))[(x)])
instance GetPixel (Image GrayScale D32) where
    type P (Image GrayScale D32) = D32
    {-#INLINE getPixel#-}
    getPixel (x,y) i = unsafePerformIO $
                        withGenImage i $ \c_i -> do
