 
 emptyCopy img = create (getSize img) 
 
+-- | Save image. This will convert the image to 8 bit one before saving
 saveImage :: FilePath -> Image c d -> IO ()
 saveImage filename image = do
-                           fpi <- imageTo8Bit image
+                           fpi <- imageTo8Bit $ unS image
                            withCString  filename $ \name  -> 
-                            withGenImage fpi    $ \cvArr ->
+                            withGenBareImage fpi    $ \cvArr ->
 							 alloca (\defs -> poke defs 0 >> {#call cvSaveImage #} name cvArr defs >> return ())
 
---getSize image = unsafePerformIO $ withImage image $ \i -> do
---                 w <- {#call getImageWidth#} i
---                 h <- {#call getImageHeight#} i
---                 return (fromIntegral w,fromIntegral h)
-
+
+getArea :: (IntSized a) => a -> Int
 getArea = uncurry (*).getSize
 
-getRegion :: (Integral a) => (a,a) -> (a,a) -> Image c d -> Image c d
+getRegion :: (Int,Int) -> (Int,Int) -> Image c d -> Image c d
 getRegion (fromIntegral -> x,fromIntegral -> y) (fromIntegral -> w,fromIntegral -> h) image 
     | x+w <= width && y+h <= height = S . getRegion' (x,y) (w,h) $ unS image
     | otherwise                   = error $ "Region outside image:"
                                             ++ show (getSize image) ++
                                             "/"++show (x+w,y+h)
  where
-  (width,height) = getSize image
+  (fromIntegral -> width,fromIntegral -> height) = getSize image
     
 getRegion' (x,y) (w,h) image = unsafePerformIO $
-                               withImage image $ \i ->
-                                 creatingImage ({#call getSubImage#} 
+                               withBareImage image $ \i ->
+                                 creatingBareImage ({#call getSubImage#} 
                                                 i x y w h)
 
 

subPixelBlit
  :: Image c d -> Image c d -> (CDouble, CDouble) -> IO ()

subPixelBlit (unS -> image1) (unS -> image2) (x,y) 
    | badSizes  = error $ "Bad blit sizes: " ++ show [(w1,h1),(w2,h2)]++"<-"++show (x,y) 
    | otherwise = withImage image1 $ \i1 ->
                   withImage image2 $ \i2 ->

     (xstep,ystep) = (fromIntegral space + w,fromIntegral space + h)
     edge = space`div`2
     resultPic = unsafePerformIO $ do
                    r <- create (rw,rh)
                    sequence_ [blit r i (edge +  x*xstep, edge + y*ystep) | y <- [0..v-1] , x <- [0..u-1] | i <- imgs ]
                    return r

