diff --git a/Graphics/Imlib.hs b/Graphics/Imlib.hs
--- a/Graphics/Imlib.hs
+++ b/Graphics/Imlib.hs
@@ -154,7 +154,7 @@
     polygonContainsPoint, imageDrawEllipse, imageFillEllipse, imageFilter, 
     createFilter, freeFilter, filterSet, filterSetAlpha, filterSetRed, 
     filterSetGreen, filterSetBlue, filterConstants, filterDivisors,
-    createImageUsingArray, withImageBits, withImage
+    createImageUsingArray, withImageBits, withImage, colorFromBits, colorToBits
 )
 where
 
@@ -198,7 +198,7 @@
 newtype ImlibFilter = ImlibFilter (Ptr ImlibFilter)
 newtype ImlibPolygon = ImlibPolygon (Ptr ImlibPolygon)
 
-data ImlibBorder = ImlibBorder Int Int Int Int deriving (Show, Eq) -- left, right, top, bottom
+data ImlibBorder = ImlibBorder CInt CInt CInt CInt deriving (Show, Eq) -- left, right, top, bottom
 instance Storable ImlibBorder where
     sizeOf _ = 16
     alignment _ = 4
@@ -258,11 +258,11 @@
 
 type ImlibProgressFunction = ImlibImage -- image
                             -> Word8    -- percent
-                            -> Int      -- update x
-                            -> Int      -- update y
-                            -> Int      -- update w
-                            -> Int      -- update h
-                            -> IO Int   -- return value (not sure what this means)
+                            -> CInt      -- update x
+                            -> CInt      -- update y
+                            -> CInt      -- update w
+                            -> CInt      -- update h
+                            -> IO CInt   -- return value (not sure what this means)
 foreign import ccall "wrapper" mkProgressFunction :: ImlibProgressFunction -> IO (FunPtr ImlibProgressFunction)
 
 colorToBits :: ImlibColor -> Word32
@@ -306,9 +306,9 @@
 contextSetColorModifier = imlibContextSetColorModifier
 
 --void imlib_context_set_operation(Imlib_Operation operation);
-foreign import ccall "static Imlib2.h imlib_context_set_operation" imlibContextSetOperation :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_set_operation" imlibContextSetOperation :: CInt -> IO ()
 contextSetOperation :: ImlibOperation -> IO ()
-contextSetOperation op = imlibContextSetOperation (fromEnum op)
+contextSetOperation op = imlibContextSetOperation (fromIntegral $ fromEnum op)
 
 --void imlib_context_set_font(Imlib_Font font);
 foreign import ccall "static Imlib2.h imlib_context_set_font" imlibContextSetFont :: ImlibFont -> IO ()
@@ -316,32 +316,32 @@
 contextSetFont = imlibContextSetFont
 
 --void imlib_context_set_direction(Imlib_Text_Direction direction);
-foreign import ccall "static Imlib2.h imlib_context_set_direction" imlibContextSetDirection :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_set_direction" imlibContextSetDirection :: CInt -> IO ()
 contextSetDirection :: ImlibTextDirection -> IO ()
-contextSetDirection dir = imlibContextSetDirection (fromEnum dir)
+contextSetDirection dir = imlibContextSetDirection (fromIntegral $ fromEnum dir)
 
 --void imlib_context_set_angle(double angle);
-foreign import ccall "static Imlib2.h imlib_context_set_angle" imlibContextSetAngle :: Double -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_set_angle" imlibContextSetAngle :: CDouble -> IO ()
 contextSetAngle :: Double -> IO ()
-contextSetAngle = imlibContextSetAngle
+contextSetAngle = imlibContextSetAngle . realToFrac
 
 --void imlib_context_set_color(int red, int green, int blue, int alpha);
-foreign import ccall "static Imlib2.h imlib_context_set_color" imlibContextSetColor :: Int -> Int -> Int -> Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_set_color" imlibContextSetColor :: CInt -> CInt -> CInt -> CInt -> IO ()
 contextSetColor :: Int -> Int -> Int -> Int -> IO ()
-contextSetColor = imlibContextSetColor
+contextSetColor r g b a = imlibContextSetColor (fromIntegral r) (fromIntegral g) (fromIntegral b) (fromIntegral a)
 
 --void imlib_context_set_color_cmya(int cyan, magenta, int yellow, int alpha);
-foreign import ccall "static Imlib2.h imlib_context_set_color_cmya" imlibContextSetColorCmya :: Int -> Int -> Int -> Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_set_color_cmya" imlibContextSetColorCmya :: CInt -> CInt -> CInt -> CInt -> IO ()
 contextSetColorCmya :: Int -> Int -> Int -> Int -> IO ()
-contextSetColorCmya = imlibContextSetColorCmya
+contextSetColorCmya c m y a = imlibContextSetColorCmya (fromIntegral c) (fromIntegral m) (fromIntegral y) (fromIntegral a)
 
 --void imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha);
-foreign import ccall "static Imlib2.h imlib_context_set_color_hsva" imlibContextSetColorHsva :: Int -> Int -> Int -> Int -> IO ()
-contextSetColorHsva = imlibContextSetColorHsva
+foreign import ccall "static Imlib2.h imlib_context_set_color_hsva" imlibContextSetColorHsva :: CInt -> CInt -> CInt -> CInt -> IO ()
+contextSetColorHsva h s v a = imlibContextSetColorHsva (fromIntegral h) (fromIntegral s) (fromIntegral v) (fromIntegral a)
 
 --void imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha);
-foreign import ccall "static Imlib2.h imlib_context_set_color_hlsa" imlibContextSetColorHlsa :: Int -> Int -> Int -> Int -> IO ()
-contextSetColorHlsa = imlibContextSetColorHlsa
+foreign import ccall "static Imlib2.h imlib_context_set_color_hlsa" imlibContextSetColorHlsa :: CInt -> CInt -> CInt -> CInt -> IO ()
+contextSetColorHlsa h l s a = imlibContextSetColorHlsa (fromIntegral h) (fromIntegral l) (fromIntegral s) (fromIntegral a)
 
 --void imlib_context_set_color_range(Imlib_Color_Range color_range);
 foreign import ccall "static Imlib2.h imlib_context_set_color_range" imlibContextSetColorRange :: ImlibColorRange -> IO ()
@@ -395,11 +395,11 @@
 contextGetColorModifier = imlibContextGetColorModifier
 
 -- Imlib_Operation imlib_context_get_operation(void);
-foreign import ccall "static Imlib2.h imlib_context_get_operation" imlibContextGetOperation :: IO Int
+foreign import ccall "static Imlib2.h imlib_context_get_operation" imlibContextGetOperation :: IO CInt
 contextGetOperation :: IO ImlibOperation
 contextGetOperation = do
     i <- imlibContextGetOperation
-    return (toEnum i)
+    return (toEnum $ fromIntegral i)
 
 -- Imlib_Font imlib_context_get_font(void);
 foreign import ccall "static Imlib2.h imlib_context_get_font" imlibContextGetFont :: IO ImlibFont
@@ -407,54 +407,54 @@
 contextGetFont = imlibContextGetFont
 
 -- double imlib_context_get_angle(void);
-foreign import ccall "static Imlib2.h imlib_context_get_angle" imlibContextGetAngle :: IO Double
+foreign import ccall "static Imlib2.h imlib_context_get_angle" imlibContextGetAngle :: IO CDouble
 contextGetAngle :: IO Double
-contextGetAngle = imlibContextGetAngle
+contextGetAngle = imlibContextGetAngle >>= return . realToFrac
 
 -- Imlib_Text_Direction imlib_context_get_direction(void);
-foreign import ccall "static Imlib2.h imlib_context_get_direction" imlibContextGetDirection :: IO Int
+foreign import ccall "static Imlib2.h imlib_context_get_direction" imlibContextGetDirection :: IO CInt
 contextGetDirection :: IO ImlibTextDirection
 contextGetDirection = do
     d <- imlibContextGetDirection
-    return (toEnum d)
+    return (toEnum $ fromIntegral d)
 
 -- void imlib_context_get_color(int *red, int *green, int *blue, int *alpha);
-foreign import ccall "static Imlib2.h imlib_context_get_color" imlibContextGetColor :: Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_get_color" imlibContextGetColor :: Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 contextGetColor :: IO (Int, Int, Int, Int)
 contextGetColor = do
     [r,g,b,a] <- nmalloc 4
     imlibContextGetColor r g b a
-    [rr,gg,bb,aa] <- mapM peek [r,g,b,a]
+    [rr,gg,bb,aa] <- liftM (map fromIntegral) $ mapM peek [r,g,b,a]
     mapM free [r,g,b,a]
     return (rr,gg,bb,aa)
 
 -- void imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha);
-foreign import ccall "static Imlib2.h imlib_context_get_color_cmya" imlibContextGetColorCmya :: Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_get_color_cmya" imlibContextGetColorCmya :: Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 contextGetColorCmya :: IO (Int, Int, Int, Int)
 contextGetColorCmya = do
     [c,m,y,a] <- nmalloc 4
     imlibContextGetColorCmya c m y a
-    [cc,mm,yy,aa] <- mapM peek [c,m,y,a]
+    [cc,mm,yy,aa] <- liftM (map fromIntegral) $ mapM peek [c,m,y,a]
     mapM free [c,m,y,a]
     return (cc,mm,yy,aa)
 
 -- void imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha);
-foreign import ccall "static Imlib2.h imlib_context_get_color_hsva" imlibContextGetColorHsva :: Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_get_color_hsva" imlibContextGetColorHsva :: Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 contextGetColorHsva :: IO (Int, Int, Int, Int)
 contextGetColorHsva = do
     [h,s,v,a] <- nmalloc 4
     imlibContextGetColorHsva h s v a
-    [hh,ss,vv,aa] <- mapM peek [h,s,v,a]
+    [hh,ss,vv,aa] <- liftM (map fromIntegral) $ mapM peek [h,s,v,a]
     mapM free [h,s,v,a]
     return (hh,ss,vv,aa)
 
 -- void imlib_context_get_color_hlsa(float *hue, float * lightness, float *saturation, int *alpha);
-foreign import ccall "static Imlib2.h imlib_context_get_color_hlsa" imlibContextGetColorHlsa :: Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_context_get_color_hlsa" imlibContextGetColorHlsa :: Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 contextGetColorHlsa :: IO (Int, Int, Int, Int)
 contextGetColorHlsa = do
     [h,l,s,a] <- nmalloc 4
     imlibContextGetColorHlsa h l s a
-    [hh,ll,ss,aa] <- mapM peek [h,l,s,a]
+    [hh,ll,ss,aa] <- liftM (map fromIntegral) $ mapM peek [h,l,s,a]
     mapM free [h,l,s,a]
     return (hh,ll,ss,aa)
 
@@ -492,9 +492,9 @@
 contextGetFilter = imlibContextGetFilter
 
 -- int imlib_get_cache_size(void);
-foreign import ccall "static Imlib2.h imlib_get_cache_size" imlibGetCacheSize :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_cache_size" imlibGetCacheSize :: IO CInt
 getCacheSize :: IO Int
-getCacheSize = imlibGetCacheSize
+getCacheSize = imlibGetCacheSize >>= return . fromIntegral
 
 -- void imlib_set_cache_size(int bytes);
 foreign import ccall "static Imlib2.h imlib_set_cache_size" imlibSetCacheSize :: Int -> IO ()
@@ -502,14 +502,14 @@
 setCacheSize = imlibSetCacheSize
 
 -- int imlib_get_color_usage(void);
-foreign import ccall "static Imlib2.h imlib_get_color_usage" imlibGetColorUsage :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_color_usage" imlibGetColorUsage :: IO CInt
 getColorUsage :: IO Int
-getColorUsage = imlibGetColorUsage
+getColorUsage = imlibGetColorUsage >>= return . fromIntegral
 
 -- void imlib_set_color_usage(int max);
-foreign import ccall "static Imlib2.h imlib_set_color_usage" imlibSetColorUsage :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_set_color_usage" imlibSetColorUsage :: CInt -> IO ()
 setColorUsage :: Int -> IO ()
-setColorUsage = imlibSetColorUsage
+setColorUsage = imlibSetColorUsage . fromIntegral
 
 -- void imlib_flush_loaders(void);
 foreign import ccall "static Imlib2.h imlib_flush_loaders" imlibFlushLoaders :: IO ()
@@ -536,14 +536,14 @@
 loadImageImmediatelyWithoutCache str = withCString str imlibLoadImageImmediatelyWithoutCache
 
 --Imlib_Image imlib_load_image_with_error_return(const char *file, Imlib_Load_Error *error_return);
-foreign import ccall "static Imlib2.h imlib_load_image_with_error_return" imlibLoadImageWithErrorReturn :: CString -> Ptr Int -> IO ImlibImage
+foreign import ccall "static Imlib2.h imlib_load_image_with_error_return" imlibLoadImageWithErrorReturn :: CString -> Ptr CInt -> IO ImlibImage
 loadImageWithErrorReturn :: String -> IO (ImlibImage, ImlibLoadError)
 loadImageWithErrorReturn str = do
     pe <- malloc
     im <- withCString str (\s -> imlibLoadImageWithErrorReturn s pe)
     e <- peek pe
     free pe
-    return (im, toEnum e)
+    return (im, toEnum $ fromIntegral e)
 
 --void imlib_free_image(void);
 foreign import ccall "static Imlib2.h imlib_free_image" imlibFreeImage :: IO ()
@@ -556,14 +556,14 @@
 freeImageAndDecache = imlibFreeImageAndDecache
 
 --int imlib_image_get_width(void);
-foreign import ccall "static Imlib2.h imlib_image_get_width" imlibImageGetWidth :: IO Int
+foreign import ccall "static Imlib2.h imlib_image_get_width" imlibImageGetWidth :: IO CInt
 imageGetWidth :: IO Int
-imageGetWidth = imlibImageGetWidth
+imageGetWidth = imlibImageGetWidth >>= return . fromIntegral
 
 --int imlib_image_get_height(void);
-foreign import ccall "static Imlib2.h imlib_image_get_height" imlibImageGetHeight :: IO Int
+foreign import ccall "static Imlib2.h imlib_image_get_height" imlibImageGetHeight :: IO CInt
 imageGetHeight :: IO Int
-imageGetHeight = imlibImageGetHeight
+imageGetHeight = imlibImageGetHeight >>= return . fromIntegral
 
 --const char *imlib_image_get_filename(void);
 foreign import ccall "static Imlib2.h imlib_image_get_filename" imlibImageGetFilename :: IO CString
@@ -683,30 +683,30 @@
 foreign import ccall "static Imlib2.h imlib_blend_image_onto_image" imlibBlendImageOntoImage
     :: ImlibImage
     -> Bool  -- merge alpha
-    -> Int   -- source x
-    -> Int   -- source y
-    -> Int   -- source width
-    -> Int   -- source height
-    -> Int   -- dest x
-    -> Int   -- dest y
-    -> Int   -- dest width
-    -> Int   -- dest height
+    -> CInt   -- source x
+    -> CInt   -- source y
+    -> CInt   -- source width
+    -> CInt   -- source height
+    -> CInt   -- dest x
+    -> CInt   -- dest y
+    -> CInt   -- dest width
+    -> CInt   -- dest height
     -> IO ()
-blendImageOntoImage mergeAlpha (sx, sy, sw, sh) (dx, dy, dw, dh) = imlibBlendImageOntoImage mergeAlpha sx sy sw sh dx dy dw dh
+blendImageOntoImage img mergeAlpha (sx, sy, sw, sh) (dx, dy, dw, dh) = imlibBlendImageOntoImage img mergeAlpha (fromIntegral sx) (fromIntegral sy) (fromIntegral sw) (fromIntegral sh) (fromIntegral dx) (fromIntegral dy) (fromIntegral dw) (fromIntegral dh)
 
 --Imlib_Image imlib_create_image(int width, int height);
-foreign import ccall "static Imlib2.h imlib_create_image" imlibCreateImage :: Int -> Int -> IO ImlibImage
+foreign import ccall "static Imlib2.h imlib_create_image" imlibCreateImage :: CInt -> CInt -> IO ImlibImage
 createImage :: Int -> Int -> IO ImlibImage
-createImage = imlibCreateImage
+createImage w h = imlibCreateImage (fromIntegral w) (fromIntegral h)
 
 --Imlib_Image imlib_create_image_using_data(int width, int height, DATA32 *data);
-foreign import ccall "static Imlib2.h imlib_create_image_using_data" imlibCreateImageUsingData :: Int -> Int -> Ptr Word32 -> IO ImlibImage
+foreign import ccall "static Imlib2.h imlib_create_image_using_data" imlibCreateImageUsingData :: CInt -> CInt -> Ptr Word32 -> IO ImlibImage
 createImageUsingData :: Int -> Int -> Ptr Word32 -> IO ImlibImage
-createImageUsingData = imlibCreateImageUsingData
+createImageUsingData w h ptr = imlibCreateImageUsingData (fromIntegral w) (fromIntegral h) ptr
 
 --Imlib_Image imlib_create_image_using_copied_data(int width, int height, DATA32 *data);
-foreign import ccall "static Imlib2.h imlib_create_image_using_copied_data" imlibCreateImageUsingCopiedData :: Int -> Int -> Ptr(Word32) -> IO ImlibImage
-createImageUsingCopiedData = imlibCreateImageUsingCopiedData
+foreign import ccall "static Imlib2.h imlib_create_image_using_copied_data" imlibCreateImageUsingCopiedData :: CInt -> CInt -> Ptr(Word32) -> IO ImlibImage
+createImageUsingCopiedData w h ptr  = imlibCreateImageUsingCopiedData (fromIntegral w) (fromIntegral h) ptr
 
 createImageUsingList :: Int -> Int -> [ImlibColor] -> IO ImlibImage
 createImageUsingList w h xs = withArray (map colorToBits xs) (createImageUsingCopiedData w h)
@@ -721,12 +721,12 @@
 cloneImage = imlibCloneImage
 
 --Imlib_Image imlib_create_cropped_image(int x, int y, int width, int height);
-foreign import ccall "static Imlib2.h imlib_create_cropped_image" imlibCreateCroppedImage :: Int -> Int -> Int -> Int -> IO ImlibImage
-createCroppedImage = imlibCreateCroppedImage
+foreign import ccall "static Imlib2.h imlib_create_cropped_image" imlibCreateCroppedImage :: CInt -> CInt -> CInt -> CInt -> IO ImlibImage
+createCroppedImage x y w h = imlibCreateCroppedImage (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
 
 --Imlib_Image imlib_create_cropped_scaled_image(int source_x, int source_y, int source_width, int source_height, int destination_width, int destination_height);
-foreign import ccall "static Imlib2.h imlib_create_cropped_scaled_image" imlibCreateCroppedScaledImage :: Int -> Int -> Int -> Int -> Int -> Int -> IO ImlibImage
-createCroppedScaledImage = imlibCreateCroppedScaledImage
+foreign import ccall "static Imlib2.h imlib_create_cropped_scaled_image" imlibCreateCroppedScaledImage :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ImlibImage
+createCroppedScaledImage sx sy sw sh dw dh = imlibCreateCroppedScaledImage (fromIntegral sx) (fromIntegral sy) (fromIntegral sw) (fromIntegral sh) (fromIntegral dw) (fromIntegral dh)
 
 --Imlib_Updates imlib_updates_clone(Imlib_Updates updates);
 foreign import ccall "static Imlib2.h imlib_updates_clone" imlibUpdatesClone :: ImlibUpdates -> IO ImlibUpdates
@@ -734,16 +734,16 @@
 updatesClone = imlibUpdatesClone
 
 --Imlib_Updates imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h);
-foreign import ccall "static Imlib2.h imlib_update_append_rect" imlibUpdateAppendRect :: ImlibUpdates -> Int -> Int -> Int -> Int -> IO ImlibUpdates
-updateAppendRect = imlibUpdateAppendRect
+foreign import ccall "static Imlib2.h imlib_update_append_rect" imlibUpdateAppendRect :: ImlibUpdates -> CInt -> CInt -> CInt -> CInt -> IO ImlibUpdates
+updateAppendRect u x y w h = imlibUpdateAppendRect u (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
 
 --Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h);
-foreign import ccall "static Imlib2.h imlib_updates_merge" imlibUpdatesMerge :: ImlibUpdates -> Int -> Int -> IO ImlibUpdates
-updatesMerge = imlibUpdatesMerge
+foreign import ccall "static Imlib2.h imlib_updates_merge" imlibUpdatesMerge :: ImlibUpdates -> CInt -> CInt -> IO ImlibUpdates
+updatesMerge u w h = imlibUpdatesMerge u (fromIntegral w) (fromIntegral h)
 
 --Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h);
-foreign import ccall "static Imlib2.h imlib_updates_merge_for_rendering" imlibUpdatesMergeForRendering :: ImlibUpdates -> Int -> Int -> IO ImlibUpdates
-updatesMergeForRendering = imlibUpdatesMergeForRendering
+foreign import ccall "static Imlib2.h imlib_updates_merge_for_rendering" imlibUpdatesMergeForRendering :: ImlibUpdates -> CInt -> CInt -> IO ImlibUpdates
+updatesMergeForRendering u w h = imlibUpdatesMergeForRendering u (fromIntegral w) (fromIntegral h)
 
 --void imlib_updates_free(Imlib_Updates updates);
 foreign import ccall "static Imlib2.h imlib_updates_free" imlibUpdatesFree :: ImlibUpdates -> IO ()
@@ -756,18 +756,18 @@
 updatesGetNext = imlibUpdatesGetNext
 
 --void imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return, int *y_return, int *width_return, int *height_return);
-foreign import ccall "static Imlib2.h imlib_updates_get_coordinates" imlibUpdatesGetCoordinates :: ImlibUpdates -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_updates_get_coordinates" imlibUpdatesGetCoordinates :: ImlibUpdates -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 updatesGetCoordinates :: ImlibUpdates -> IO (Int, Int, Int, Int)
 updatesGetCoordinates u = do
     [x,y,w,h] <- nmalloc 4
     imlibUpdatesGetCoordinates u x y w h
-    [xx,yy,ww,hh] <- mapM peek [x,y,w,h]
+    [xx,yy,ww,hh] <- liftM (map fromIntegral) $ mapM peek [x,y,w,h]
     mapM free [x,y,w,h]
     return (xx,yy,ww,hh)
 
 --void imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, int width, int height);
-foreign import ccall "static Imlib2.h imlib_updates_set_coordinates" imlibUpdatesSetCoordinates :: ImlibUpdates -> Int -> Int -> Int -> Int -> IO ()
-updatesSetCoordinates = imlibUpdatesSetCoordinates
+foreign import ccall "static Imlib2.h imlib_updates_set_coordinates" imlibUpdatesSetCoordinates :: ImlibUpdates -> CInt -> CInt -> CInt -> CInt -> IO ()
+updatesSetCoordinates u x y w h = imlibUpdatesSetCoordinates u (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
 
 --Imlib_Updates imlib_updates_init(void);
 foreign import ccall "static Imlib2.h imlib_updates_init" imlibUpdatesInit :: IO ImlibUpdates
@@ -794,19 +794,19 @@
 imageFlipDiagonal = imlibImageFlipDiagonal
 
 --void imlib_image_orientate(int orientation);
-foreign import ccall "static Imlib2.h imlib_image_orientate" imlibImageOrientate :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_orientate" imlibImageOrientate :: CInt -> IO ()
 imageOrientate :: Int -> IO ()
-imageOrientate = imlibImageOrientate
+imageOrientate = imlibImageOrientate . fromIntegral
 
 --void imlib_image_blur(int radius);
-foreign import ccall "static Imlib2.h imlib_image_blur" imlibImageBlur :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_blur" imlibImageBlur :: CInt -> IO ()
 imageBlur :: Int -> IO ()
-imageBlur = imlibImageBlur
+imageBlur = imlibImageBlur . fromIntegral
 
 --void imlib_image_sharpen(int radius);
-foreign import ccall "static Imlib2.h imlib_image_sharpen" imlibImageSharpen :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_sharpen" imlibImageSharpen :: CInt -> IO ()
 imageSharpen :: Int -> IO ()
-imageSharpen = imlibImageSharpen
+imageSharpen = imlibImageSharpen . fromIntegral
 
 --void imlib_image_tile_horizontal(void);
 foreign import ccall "static Imlib2.h imlib_image_tile_horizontal" imlibImageTileHorizontal :: IO ()
@@ -835,43 +835,43 @@
 
 
 --void imlib_text_draw(int x, int y, const char *text);
-foreign import ccall "static Imlib2.h imlib_text_draw" imlibTextDraw :: Int -> Int -> CString -> IO ()
+foreign import ccall "static Imlib2.h imlib_text_draw" imlibTextDraw :: CInt -> CInt -> CString -> IO ()
 textDraw :: Int -> Int -> String -> IO ()
-textDraw x y str = withCString str (imlibTextDraw x y)
+textDraw x y str = withCString str (imlibTextDraw (fromIntegral x) (fromIntegral y))
 
 --void imlib_text_draw_with_return_metrics(int x, int y, const char *text, int *width_return, int *height_return, int *horizontal_advance_return, int *vertical_advance_return);
-foreign import ccall "static Imlib2.h imlib_text_draw_with_return_metrics" imlibTextDrawWithReturnMetrics :: Int -> Int -> CString -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_text_draw_with_return_metrics" imlibTextDrawWithReturnMetrics :: CInt -> CInt -> CString -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 textDrawWithReturnMetrics x y str = do
     [w,h,ah,av] <- nmalloc 4
-    withCString str (\s -> imlibTextDrawWithReturnMetrics x y s w h ah av)
-    [rw,rh,rah,rav] <- mapM peek [w,h,ah,av]
+    withCString str (\s -> imlibTextDrawWithReturnMetrics (fromIntegral x) (fromIntegral y) s w h ah av)
+    [rw,rh,rah,rav] <- liftM (map fromIntegral) $ mapM peek [w,h,ah,av]
     mapM free [w,h,ah,av]
     return (rw,rh,rah,rav)
 
 --void imlib_get_text_size(const char *text, int *width_return, int *height_return);
-foreign import ccall "static Imlib2.h imlib_get_text_size" imlibGetTextSize :: CString -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_get_text_size" imlibGetTextSize :: CString -> Ptr CInt -> Ptr CInt -> IO ()
 getTextSize :: String -> IO (Int, Int)
 getTextSize str = do
-    [w,h] <- nmalloc 4
+    [w,h] <- nmalloc 2
     withCString str (\s -> imlibGetTextSize s w h)
     [rw,rh] <- mapM peek [w,h]
     mapM free [w,h]
-    return (rw,rh)
+    return (fromIntegral rw,fromIntegral rh)
 
 --void imlib_get_text_advance(const char *text, int *horizontal_advance_return, int *vertical_advance_return);
-foreign import ccall "static Imlib2.h imlib_get_text_advance" imlibGetTextAdvance :: CString -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_get_text_advance" imlibGetTextAdvance :: CString -> Ptr CInt -> Ptr CInt -> IO ()
 getTextAdvance :: String -> IO (Int, Int)
 getTextAdvance str = do
-    [h,v] <- nmalloc 4
+    [h,v] <- nmalloc 2
     withCString str (\s -> imlibGetTextAdvance s h v)
     [rh,rv] <- mapM peek [h,v]
     mapM free [h,v]
-    return (rh,rv)
+    return (fromIntegral rh,fromIntegral rv)
 
 --int imlib_get_text_inset(const char *text);
-foreign import ccall "static Imlib2.h imlib_get_text_inset" imlibGetTextInset :: CString -> IO Int
+foreign import ccall "static Imlib2.h imlib_get_text_inset" imlibGetTextInset :: CString -> IO CInt
 getTextInset :: String -> IO Int
-getTextInset str = withCString str imlibGetTextInset
+getTextInset str = withCString str $ liftM fromIntegral . imlibGetTextInset
 
 --void imlib_add_path_to_font_path(const char *path);
 foreign import ccall "static Imlib2.h imlib_add_path_to_font_path" imlibAddPathToFontPath :: CString -> IO ()
@@ -884,60 +884,60 @@
 removePathFromFontPath str = withCString str imlibRemovePathFromFontPath
 
 --char **imlib_list_font_path(int *number_return);
-foreign import ccall "static Imlib2.h imlib_list_font_path" imlibListFontPath :: Ptr Int -> IO (Ptr CString)
+foreign import ccall "static Imlib2.h imlib_list_font_path" imlibListFontPath :: Ptr CInt -> IO (Ptr CString)
 listFontPath :: IO [String]
 listFontPath = do
     pn <- malloc
     pxs <- imlibListFontPath pn
     n <- peek pn
     free pn
-    xs <- peekArray n pxs
+    xs <- peekArray (fromIntegral n) pxs
     ys <- mapM peekCString xs
     return ys
 
 --int imlib_text_get_index_and_location(const char *text, int x, int y, int *char_x_return, int *char_y_return, int *char_width_return, int *char_height_return);
-foreign import ccall "static Imlib2.h imlib_text_get_index_and_location" imlibTextGetIndexAndLocation :: CString -> Int -> Int -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO Int
+foreign import ccall "static Imlib2.h imlib_text_get_index_and_location" imlibTextGetIndexAndLocation :: CString -> CInt -> CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO CInt
 textGetIndexAndLocation str x y = do
     [xp,yp,wp,hp] <- nmalloc 4
     n <- withCString str (\s -> imlibTextGetIndexAndLocation s x y xp yp wp hp)
     [xr,yr,wr,hr] <- mapM peek [xp,yp,wp,hp]
     mapM free [xp,yp,wp,hp]
-    return (n,xr,yr,wr,hr)
+    return (fromIntegral n, fromIntegral xr, fromIntegral yr, fromIntegral wr, fromIntegral hr)
 
 
 --void imlib_text_get_location_at_index(const char *text, int index, int *char_x_return, int *char_y_return, int *char_width_return, int *char_height_return);
-foreign import ccall "static Imlib2.h imlib_text_get_location_at_index" imlibTextGetLocationAtIndex :: CString -> Int -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_text_get_location_at_index" imlibTextGetLocationAtIndex :: CString -> CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 textGetLocationAtIndex str k = do
     [xp,yp,wp,hp] <- nmalloc 4
     withCString str (\s -> imlibTextGetLocationAtIndex s k xp yp wp hp)
     [xr,yr,wr,hr] <- mapM peek [xp,yp,wp,hp]
     mapM free [xp,yp,wp,hp]
-    return (xr,yr,wr,hr)
+    return (fromIntegral xr, fromIntegral yr, fromIntegral wr, fromIntegral hr)
 
 --char **imlib_list_fonts(int *number_return);
 --void imlib_free_font_list(char **font_list, int number);
-foreign import ccall "static Imlib2.h imlib_list_fonts" imlibListFonts :: Ptr Int -> IO (Ptr CString)
-foreign import ccall "static Imlib2.h imlib_free_font_list" imlibFreeFontList :: Ptr (CString) -> Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_list_fonts" imlibListFonts :: Ptr CInt -> IO (Ptr CString)
+foreign import ccall "static Imlib2.h imlib_free_font_list" imlibFreeFontList :: Ptr (CString) -> CInt -> IO ()
 listFonts :: IO [String]
 listFonts = do
     pn <- malloc
     pxs <- imlibListFonts pn
     n <- peek pn
     free pn
-    xs <- peekArray n pxs
+    xs <- peekArray (fromIntegral n) pxs
     ys <- mapM peekCString xs
     imlibFreeFontList pxs n
     return ys
 
 --int imlib_get_font_cache_size(void);
-foreign import ccall "static Imlib2.h imlib_get_font_cache_size" imlibGetFontCacheSize :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_font_cache_size" imlibGetFontCacheSize :: IO CInt
 getFontCacheSize :: IO Int
-getFontCacheSize = imlibGetFontCacheSize
+getFontCacheSize = liftM fromIntegral imlibGetFontCacheSize
 
 --void imlib_set_font_cache_size(int bytes);
-foreign import ccall "static Imlib2.h imlib_set_font_cache_size" imlibSetFontCacheSize :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_set_font_cache_size" imlibSetFontCacheSize :: CInt -> IO ()
 setFontCacheSize :: Int -> IO ()
-setFontCacheSize = imlibSetFontCacheSize
+setFontCacheSize = imlibSetFontCacheSize . fromIntegral
 
 --void imlib_flush_font_cache(void);
 foreign import ccall "static Imlib2.h imlib_flush_font_cache" imlibFlushFontCache :: IO ()
@@ -945,24 +945,24 @@
 flushFontCache = imlibFlushFontCache
 
 --int imlib_get_font_ascent(void);
-foreign import ccall "static Imlib2.h imlib_get_font_ascent" imlibGetFontAscent :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_font_ascent" imlibGetFontAscent :: IO CInt
 getFontAscent :: IO Int
-getFontAscent = imlibGetFontAscent
+getFontAscent = liftM fromIntegral imlibGetFontAscent
 
 --int imlib_get_font_descent(void);
-foreign import ccall "static Imlib2.h imlib_get_font_descent" imlibGetFontDescent :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_font_descent" imlibGetFontDescent :: IO CInt
 getFontDescent :: IO Int
-getFontDescent = imlibGetFontDescent
+getFontDescent = liftM fromIntegral imlibGetFontDescent
 
 --int imlib_get_maximum_font_ascent(void);
-foreign import ccall "static Imlib2.h imlib_get_maximum_font_ascent" imlibGetMaximumFontAscent :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_maximum_font_ascent" imlibGetMaximumFontAscent :: IO CInt
 getMaximumFontAscent :: IO Int
-getMaximumFontAscent = imlibGetMaximumFontAscent
+getMaximumFontAscent = liftM fromIntegral imlibGetMaximumFontAscent
 
 --int imlib_get_maximum_font_descent(void);
-foreign import ccall "static Imlib2.h imlib_get_maximum_font_descent" imlibGetMaximumFontDescent :: IO Int
+foreign import ccall "static Imlib2.h imlib_get_maximum_font_descent" imlibGetMaximumFontDescent :: IO CInt
 getMaximumFontDescent :: IO Int
-getMaximumFontDescent = imlibGetMaximumFontDescent
+getMaximumFontDescent = liftM fromIntegral imlibGetMaximumFontDescent
 
 --Imlib_Color_Modifier imlib_create_color_modifier(void);
 foreign import ccall "static Imlib2.h imlib_create_color_modifier" imlibCreateColorModifier :: IO ImlibColorModifier
@@ -975,19 +975,19 @@
 freeColorModifier = imlibFreeColorModifier
 
 --void imlib_modify_color_modifier_gamma(double gamma_value);
-foreign import ccall "static Imlib2.h imlib_modify_color_modifier_gamma" imlibModifyColorModifierGamma :: Double -> IO ()
+foreign import ccall "static Imlib2.h imlib_modify_color_modifier_gamma" imlibModifyColorModifierGamma :: CDouble -> IO ()
 modifyColorModifierGamma :: Double -> IO ()
-modifyColorModifierGamma = imlibModifyColorModifierGamma
+modifyColorModifierGamma = imlibModifyColorModifierGamma . fromRational . toRational
 
 --void imlib_modify_color_modifier_brightness(double brightness_value);
-foreign import ccall "static Imlib2.h imlib_modify_color_modifier_brightness" imlibModifyColorModifierBrightness :: Double -> IO ()
+foreign import ccall "static Imlib2.h imlib_modify_color_modifier_brightness" imlibModifyColorModifierBrightness :: CDouble -> IO ()
 modifyColorModifierBrightness :: Double -> IO ()
-modifyColorModifierBrightness = imlibModifyColorModifierBrightness
+modifyColorModifierBrightness = imlibModifyColorModifierBrightness . fromRational . toRational
 
 --void imlib_modify_color_modifier_contrast(double contrast_value);
-foreign import ccall "static Imlib2.h imlib_modify_color_modifier_contrast" imlibModifyColorModifierContrast :: Double -> IO ()
+foreign import ccall "static Imlib2.h imlib_modify_color_modifier_contrast" imlibModifyColorModifierContrast :: CDouble -> IO ()
 modifyColorModifierContrast :: Double -> IO ()
-modifyColorModifierContrast = imlibModifyColorModifierContrast
+modifyColorModifierContrast = imlibModifyColorModifierContrast . fromRational . toRational
 
 --void imlib_set_color_modifier_tables(DATA8 *red_table, DATA8 *green_table, DATA8 *blue_table, DATA8 *alpha_table);
 foreign import ccall "static Imlib2.h imlib_set_color_modifier_tables" imlibSetColorModifierTables :: (Ptr Word8) -> (Ptr Word8) -> (Ptr Word8) -> (Ptr Word8) -> IO ()
@@ -1026,36 +1026,46 @@
 applyColorModifier = imlibApplyColorModifier
 
 --void imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height);
-foreign import ccall "static Imlib2.h imlib_apply_color_modifier_to_rectangle" imlibApplyColorModifierToRectangle :: Int -> Int -> Int -> Int -> IO ()
-applyColorModifierToRectangle = imlibApplyColorModifierToRectangle
+foreign import ccall "static Imlib2.h imlib_apply_color_modifier_to_rectangle" imlibApplyColorModifierToRectangle :: CInt -> CInt -> CInt -> CInt -> IO ()
+applyColorModifierToRectangle :: Int -> Int -> Int -> Int -> IO ()
+applyColorModifierToRectangle x y w h = do
+    imlibApplyColorModifierToRectangle (fromIntegral x) (fromIntegral x) (fromIntegral w) (fromIntegral h)
 
 --Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates);
-foreign import ccall "static Imlib2.h imlib_image_draw_line" imlibImageDrawLine :: Int -> Int -> Int -> Int -> Bool -> IO ImlibUpdates
-imageDrawLine = imlibImageDrawLine
+foreign import ccall "static Imlib2.h imlib_image_draw_line" imlibImageDrawLine :: CInt -> CInt -> CInt -> CInt -> Bool -> IO ImlibUpdates
+imageDrawLine :: Int -> Int -> Int -> Int -> Bool -> IO ImlibUpdates
+imageDrawLine x1 y1 x2 y2 mu = do
+    imlibImageDrawLine (fromIntegral x1) (fromIntegral y1) (fromIntegral x2) (fromIntegral y2) mu
 
 --void imlib_image_draw_rectangle(int x, int y, int width, int height);
-foreign import ccall "static Imlib2.h imlib_image_draw_rectangle" imlibImageDrawRectangle :: Int -> Int -> Int -> Int -> IO ()
-imageDrawRectangle = imlibImageDrawRectangle
+foreign import ccall "static Imlib2.h imlib_image_draw_rectangle" imlibImageDrawRectangle :: CInt -> CInt -> CInt -> CInt -> IO ()
+imageDrawRectangle :: Int -> Int -> Int -> Int -> IO ()
+imageDrawRectangle x y w h = do
+    imlibImageDrawRectangle (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
 
 --void imlib_image_fill_rectangle(int x, int y, int width, int height);
-foreign import ccall "static Imlib2.h imlib_image_fill_rectangle" imlibImageFillRectangle :: Int -> Int -> Int -> Int -> IO ()
-imageFillRectangle = imlibImageFillRectangle
+foreign import ccall "static Imlib2.h imlib_image_fill_rectangle" imlibImageFillRectangle :: CInt -> CInt -> CInt -> CInt -> IO ()
+imageFillRectangle :: Int -> Int -> Int -> Int -> IO ()
+imageFillRectangle x y w h = do
+    imlibImageFillRectangle (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
 
 --void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y);
-foreign import ccall "static Imlib2.h imlib_image_copy_alpha_to_image" imlibImageCopyAlphaToImage :: ImlibImage -> Int -> Int -> IO ()
-imageCopyAlphaToImage = imlibImageCopyAlphaToImage
+foreign import ccall "static Imlib2.h imlib_image_copy_alpha_to_image" imlibImageCopyAlphaToImage :: ImlibImage -> CInt -> CInt -> IO ()
+imageCopyAlphaToImage :: ImlibImage -> Int -> Int -> IO ()
+imageCopyAlphaToImage im x y = do
+    imlibImageCopyAlphaToImage im (fromIntegral x) (fromIntegral y)
 
 --void imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, int x, int y, int width, int height, int destination_x, int destination_y);
-foreign import ccall "static Imlib2.h imlib_image_copy_alpha_rectangle_to_image" imlibImageCopyAlphaRectangleToImage :: ImlibImage -> Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-imageCopyAlphaRectangleToImage = imlibImageCopyAlphaRectangleToImage
+foreign import ccall "static Imlib2.h imlib_image_copy_alpha_rectangle_to_image" imlibImageCopyAlphaRectangleToImage :: ImlibImage -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+imageCopyAlphaRectangleToImage img x y w h dx dy = imlibImageCopyAlphaRectangleToImage img (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) (fromIntegral dx) (fromIntegral dy)
 
 --void imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x, int delta_y);
-foreign import ccall "static Imlib2.h imlib_image_scroll_rect" imlibImageScrollRect :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-imageScrollRect = imlibImageScrollRect
+foreign import ccall "static Imlib2.h imlib_image_scroll_rect" imlibImageScrollRect :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+imageScrollRect x y w h dx dy = imlibImageScrollRect (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) (fromIntegral dx) (fromIntegral dy)
 
 --void imlib_image_copy_rect(int x, int y, int width, int height, int new_x, int new_y);
-foreign import ccall "static Imlib2.h imlib_image_copy_rect" imlibImageCopyRect :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-imageCopyRect = imlibImageCopyRect
+foreign import ccall "static Imlib2.h imlib_image_copy_rect" imlibImageCopyRect :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+imageCopyRect x y w h dx dy = imlibImageCopyRect (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) (fromIntegral dx) (fromIntegral dy)
 
 --Imlib_Color_Range imlib_create_color_range(void);
 foreign import ccall "static Imlib2.h imlib_create_color_range" imlibCreateColorRange :: IO ImlibColorRange
@@ -1068,55 +1078,55 @@
 freeColorRange = imlibFreeColorRange
 
 --void imlib_add_color_to_color_range(int distance_away);
-foreign import ccall "static Imlib2.h imlib_add_color_to_color_range" imlibAddColorToColorRange :: Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_add_color_to_color_range" imlibAddColorToColorRange :: CInt -> IO ()
 addColorToColorRange :: Int -> IO ()
-addColorToColorRange = imlibAddColorToColorRange
+addColorToColorRange = imlibAddColorToColorRange . fromIntegral
 
 --void imlib_image_fill_color_range_rectangle(int x, int y, int width, int height, double angle);
-foreign import ccall "static Imlib2.h imlib_image_fill_color_range_rectangle" imlibImageFillColorRangeRectangle :: Int -> Int -> Int -> Int -> Double -> IO ()
-imageFillColorRangeRectangle = imlibImageFillColorRangeRectangle
+foreign import ccall "static Imlib2.h imlib_image_fill_color_range_rectangle" imlibImageFillColorRangeRectangle :: CInt -> CInt -> CInt -> CInt -> CDouble -> IO ()
+imageFillColorRangeRectangle x y w h a = imlibImageFillColorRangeRectangle (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) (realToFrac a)
 
 --void imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width, int height, double angle);
-foreign import ccall "static Imlib2.h imlib_image_fill_hsva_color_range_rectangle" imlibImageFillHsvaColorRangeRectangle :: Int -> Int -> Int -> Int -> Double -> IO ()
-imageFillHsvaColorRangeRectangle = imlibImageFillHsvaColorRangeRectangle
+foreign import ccall "static Imlib2.h imlib_image_fill_hsva_color_range_rectangle" imlibImageFillHsvaColorRangeRectangle :: CInt -> CInt -> CInt -> CInt -> CDouble -> IO ()
+imageFillHsvaColorRangeRectangle x y w h a = imlibImageFillHsvaColorRangeRectangle (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) (realToFrac a)
 
 --void imlib_image_query_pixel(int x, int y, Imlib_Color *color_return);
-foreign import ccall "static Imlib2.h imlib_image_query_pixel" imlibImageQueryPixel :: Int -> Int -> Ptr ImlibColor -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_query_pixel" imlibImageQueryPixel :: CInt -> CInt -> Ptr ImlibColor -> IO ()
 imageQueryPixel :: Int -> Int -> IO ImlibColor
 imageQueryPixel x y = do
     c <- malloc
-    imlibImageQueryPixel x y c
+    imlibImageQueryPixel (fromIntegral x) (fromIntegral y) c
     r <- peek c
     free c
     return r
 
 --void imlib_image_query_pixel_cmya(int x, int y, int *cyan, int *magenta, int *yellow, int *alpha);
-foreign import ccall "static Imlib2.h imlib_image_query_pixel_cmya" imlibImageQueryPixelCmya :: Int -> Int -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_query_pixel_cmya" imlibImageQueryPixelCmya :: CInt -> CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 imageQueryPixelCmya :: Int -> Int -> IO (Int, Int, Int, Int)
 imageQueryPixelCmya cx cy = do
     [c,m,y,a] <- nmalloc 4
-    imlibImageQueryPixelCmya cx cy c m y a
-    [cc,mm,yy,aa] <- mapM peek [c,m,y,a]
+    imlibImageQueryPixelCmya (fromIntegral cx) (fromIntegral cy) c m y a
+    [cc,mm,yy,aa] <- liftM (map fromIntegral) $ mapM peek [c,m,y,a]
     mapM free [c,m,y,a]
     return (cc,mm,yy,aa)
 
 --void imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation, float *value, int *alpha);
-foreign import ccall "static Imlib2.h imlib_image_query_pixel_hsva" imlibImageQueryPixelHsva :: Int -> Int -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_query_pixel_hsva" imlibImageQueryPixelHsva :: CInt -> CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 imageQueryPixelHsva :: Int -> Int -> IO (Int, Int, Int, Int)
 imageQueryPixelHsva cx cy = do
     [h,s,v,a] <- nmalloc 4
-    imlibImageQueryPixelHsva cx cy h s v a
-    [hh,ss,vv,aa] <- mapM peek [h,s,v,a]
+    imlibImageQueryPixelHsva (fromIntegral cx) (fromIntegral cy) h s v a
+    [hh,ss,vv,aa] <- liftM (map fromIntegral) $ mapM peek [h,s,v,a]
     mapM free [h,s,v,a]
     return (hh,ss,vv,aa)
 
 --void imlib_image_query_pixel_hlsa(int x, int y, float *hue, float *lightness, float *saturation, int *alpha);
-foreign import ccall "static Imlib2.h imlib_image_query_pixel_hlsa" imlibImageQueryPixelHlsa :: Int -> Int -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_image_query_pixel_hlsa" imlibImageQueryPixelHlsa :: CInt -> CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 imageQueryPixelHlsa :: Int -> Int -> IO (Int, Int, Int, Int)
 imageQueryPixelHlsa cx cy = do
     [h,l,s,a] <- nmalloc 4
-    imlibImageQueryPixelHlsa cx cy h l s a
-    [hh,ll,ss,aa] <- mapM peek [h,l,s,a]
+    imlibImageQueryPixelHlsa (fromIntegral cx) (fromIntegral cy) h l s a
+    [hh,ll,ss,aa] <- liftM (map fromIntegral) $ mapM peek [h,l,s,a]
     mapM free [h,l,s,a]
     return (hh,ll,ss,aa)
 
@@ -1132,9 +1142,9 @@
 imageGetAttachedData key = withCString key imlibImageGetAttachedData
 
 --int imlib_image_get_attached_value(const char *key);
-foreign import ccall "static Imlib2.h imlib_image_get_attached_value" imlibImageGetAttachedValue :: CString -> IO Int
+foreign import ccall "static Imlib2.h imlib_image_get_attached_value" imlibImageGetAttachedValue :: CString -> IO CInt
 imageGetAttachedValue :: String -> IO Int
-imageGetAttachedValue key = withCString key imlibImageGetAttachedValue
+imageGetAttachedValue key = withCString key imlibImageGetAttachedValue >>= return . fromIntegral
 
 --void imlib_image_remove_attached_data_value(const char *key);
 foreign import ccall "static Imlib2.h imlib_image_remove_attached_data_value" imlibImageRemoveAttachedDataValue :: CString -> IO ()
@@ -1151,49 +1161,49 @@
 saveImage str = withCString str imlibSaveImage
 
 --void imlib_save_image_with_error_return(const char *filename, Imlib_Load_Error *error_return);
-foreign import ccall "static Imlib2.h imlib_save_image_with_error_return" imlibSaveImageWithErrorReturn :: CString -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_save_image_with_error_return" imlibSaveImageWithErrorReturn :: CString -> Ptr CInt -> IO ()
 saveImageWithErrorReturn :: String -> IO ImlibLoadError
 saveImageWithErrorReturn str = do
     pe <- malloc
     im <- withCString str (\s -> imlibSaveImageWithErrorReturn s pe) -- Unused?
     e <- peek pe
     free pe
-    return (toEnum e)
+    return (toEnum $ fromIntegral e)
 
 --Imlib_Image imlib_create_rotated_image(double angle);
-foreign import ccall "static Imlib2.h imlib_create_rotated_image" imlibCreateRotatedImage :: Double -> IO ImlibImage
+foreign import ccall "static Imlib2.h imlib_create_rotated_image" imlibCreateRotatedImage :: CDouble -> IO ImlibImage
 createRotatedImage :: Double -> IO ImlibImage
-createRotatedImage = imlibCreateRotatedImage
+createRotatedImage = imlibCreateRotatedImage . realToFrac
 
 --void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image, char merge_alpha, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y, int angle_x, int angle_y);
 foreign import ccall "static Imlib2.h imlib_blend_image_onto_image_at_angle" imlibBlendImageOntoImageAtAngle :: Ptr(ImlibImage)
                                                                              -> Bool  -- merge alpha
-                                                                             -> Int   -- source x
-                                                                             -> Int   -- source y
-                                                                             -> Int   -- source width
-                                                                             -> Int   -- source height
-                                                                             -> Int   -- dest x
-                                                                             -> Int   -- dest y
-                                                                             -> Int   -- angle x
-                                                                             -> Int   -- angle y
+                                                                             -> CInt   -- source x
+                                                                             -> CInt   -- source y
+                                                                             -> CInt   -- source width
+                                                                             -> CInt   -- source height
+                                                                             -> CInt   -- dest x
+                                                                             -> CInt   -- dest y
+                                                                             -> CInt   -- angle x
+                                                                             -> CInt   -- angle y
                                                                              -> IO ()
-blendImageOntoImageAtAngle = imlibBlendImageOntoImageAtAngle
+blendImageOntoImageAtAngle ptr mergeAlpha sx sy sw sh dx dy ax ay = imlibBlendImageOntoImageAtAngle ptr mergeAlpha (fromIntegral sx) (fromIntegral sy) (fromIntegral sw) (fromIntegral sh) (fromIntegral dx) (fromIntegral dy) (fromIntegral ax) (fromIntegral ay)
 
 --void imlib_blend_image_onto_image_skewed(Imlib_Image source_image, char merge_alpha, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y, int h_angle_x, int h_angle_y, int v_angle_x, int v_angle_y);
 foreign import ccall "static Imlib2.h imlib_blend_image_onto_image_skewed" imlibBlendImageOntoImageSkewed :: Ptr(ImlibImage)
                                                                            -> Bool  -- merge alpha
-                                                                           -> Int   -- source x
-                                                                           -> Int   -- source y
-                                                                           -> Int   -- source width
-                                                                           -> Int   -- source height
-                                                                           -> Int   -- dest x
-                                                                           -> Int   -- dest y
-                                                                           -> Int   -- h angle x
-                                                                           -> Int   -- h angle y
-                                                                           -> Int   -- v angle x
-                                                                           -> Int   -- v angle y
+                                                                           -> CInt   -- source x
+                                                                           -> CInt   -- source y
+                                                                           -> CInt   -- source width
+                                                                           -> CInt   -- source height
+                                                                           -> CInt   -- dest x
+                                                                           -> CInt   -- dest y
+                                                                           -> CInt   -- h angle x
+                                                                           -> CInt   -- h angle y
+                                                                           -> CInt   -- v angle x
+                                                                           -> CInt   -- v angle y
                                                                            -> IO ()
-blendImageOntoImageSkewed = imlibBlendImageOntoImageSkewed
+blendImageOntoImageSkewed ptr mergeAlpha sx sy sw sh dx dy hx hy vx vy = imlibBlendImageOntoImageSkewed ptr mergeAlpha (fromIntegral sx) (fromIntegral sy) (fromIntegral sw) (fromIntegral sh) (fromIntegral dx) (fromIntegral dy) (fromIntegral hx) (fromIntegral hy) (fromIntegral vx) (fromIntegral vy)
 
 --void imlib_context_set_cliprect(int x, int y, int w, int h);
 foreign import ccall "static Imlib2.h imlib_context_set_cliprect" imlibContextSetCliprect :: Int -> Int -> Int -> Int -> IO ()
@@ -1221,8 +1231,8 @@
 polygonFree = imlibPolygonFree
 
 --void imlib_polygon_add_point(ImlibPolygon poly, int x, int y);
-foreign import ccall "static Imlib2.h imlib_polygon_add_point" imlibPolygonAddPoint :: ImlibPolygon -> Int -> Int -> IO ()
-polygonAddPoint = imlibPolygonAddPoint
+foreign import ccall "static Imlib2.h imlib_polygon_add_point" imlibPolygonAddPoint :: ImlibPolygon -> CInt -> CInt -> IO ()
+polygonAddPoint poly x y = imlibPolygonAddPoint poly (fromIntegral x) (fromIntegral y)
 
 --void imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed);
 foreign import ccall "static Imlib2.h imlib_image_draw_polygon" imlibImageDrawPolygon :: ImlibPolygon -> Bool -> IO ()
@@ -1235,25 +1245,25 @@
 imageFillPolygon = imlibImageFillPolygon
 
 --void imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1, int *px2, int *py2);
-foreign import ccall "static Imlib2.h imlib_polygon_get_bounds" imlibPolygonGetBounds :: ImlibPolygon -> Ptr Int -> Ptr Int -> Ptr Int -> Ptr Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_polygon_get_bounds" imlibPolygonGetBounds :: ImlibPolygon -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
 polygonGetBounds poly = do
     [x1,y1,x2,y2] <- nmalloc 4
     imlibPolygonGetBounds poly x1 y1 x2 y2
-    [rx1,ry1,rx2,ry2] <- mapM peek [x1,y1,x2,y2]
+    [rx1,ry1,rx2,ry2] <- liftM (map fromIntegral) $ mapM peek [x1,y1,x2,y2]
     mapM free [x1,y1,x2,y2]
     return (rx1,ry1,rx2,ry2)
 
 --unsigned char imlib_polygon_contains_point(ImlibPolygon poly, int x, int y);
-foreign import ccall "static Imlib2.h imlib_polygon_contains_point" imlibPolygonContainsPoint :: ImlibPolygon -> Int -> Int -> IO Bool
-polygonContainsPoint = imlibPolygonContainsPoint
+foreign import ccall "static Imlib2.h imlib_polygon_contains_point" imlibPolygonContainsPoint :: ImlibPolygon -> CInt -> CInt -> IO Bool
+polygonContainsPoint poly x y = imlibPolygonContainsPoint poly (fromIntegral x) (fromIntegral y)
 
 --void imlib_image_draw_ellipse(int xc, int yc, int a, int b);
-foreign import ccall "static Imlib2.h imlib_image_draw_ellipse" imlibImageDrawEllipse :: Int -> Int -> Int -> Int -> IO ()
-imageDrawEllipse = imlibImageDrawEllipse
+foreign import ccall "static Imlib2.h imlib_image_draw_ellipse" imlibImageDrawEllipse :: CInt -> CInt -> CInt -> CInt -> IO ()
+imageDrawEllipse xc yc a b = imlibImageDrawEllipse (fromIntegral xc) (fromIntegral yc) (fromIntegral a) (fromIntegral b)
 
 --void imlib_image_fill_ellipse(int xc, int yc, int a, int b);
-foreign import ccall "static Imlib2.h imlib_image_fill_ellipse" imlibImageFillEllipse :: Int -> Int -> Int -> Int -> IO ()
-imageFillEllipse = imlibImageFillEllipse
+foreign import ccall "static Imlib2.h imlib_image_fill_ellipse" imlibImageFillEllipse :: CInt -> CInt -> CInt -> CInt -> IO ()
+imageFillEllipse xc yc a b = imlibImageFillEllipse (fromIntegral xc) (fromIntegral yc) (fromIntegral a) (fromIntegral b)
 
 --void imlib_image_filter(void);
 foreign import ccall "static Imlib2.h imlib_image_filter" imlibImageFilter :: IO ()
@@ -1261,9 +1271,9 @@
 imageFilter = imlibImageFilter
 
 --Imlib_Filter imlib_create_filter(int initsize);
-foreign import ccall "static Imlib2.h imlib_create_filter" imlibCreateFilter :: Int -> IO ImlibFilter
+foreign import ccall "static Imlib2.h imlib_create_filter" imlibCreateFilter :: CInt -> IO ImlibFilter
 createFilter :: Int -> IO ImlibFilter
-createFilter = imlibCreateFilter
+createFilter = imlibCreateFilter . fromIntegral
 
 --void imlib_free_filter(void);
 foreign import ccall "static Imlib2.h imlib_free_filter" imlibFreeFilter :: IO ()
@@ -1271,33 +1281,33 @@
 freeFilter = imlibFreeFilter
 
 --void imlib_filter_set(int xoff, int yoff, int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_set" imlibFilterSet :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-filterSet = imlibFilterSet
+foreign import ccall "static Imlib2.h imlib_filter_set" imlibFilterSet :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+filterSet xoff yoff a r g b = imlibFilterSet (fromIntegral xoff) (fromIntegral yoff) (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_set_alpha" imlibFilterSetAlpha :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-filterSetAlpha = imlibFilterSetAlpha
+foreign import ccall "static Imlib2.h imlib_filter_set_alpha" imlibFilterSetAlpha :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+filterSetAlpha xoff yoff a r g b = imlibFilterSetAlpha (fromIntegral xoff) (fromIntegral yoff) (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_set_red" imlibFilterSetRed :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-filterSetRed = imlibFilterSetRed
+foreign import ccall "static Imlib2.h imlib_filter_set_red" imlibFilterSetRed :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+filterSetRed xoff yoff a r g b = imlibFilterSetRed (fromIntegral xoff) (fromIntegral yoff) (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_set_green(int xoff, int yoff, int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_set_green" imlibFilterSetGreen :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-filterSetGreen = imlibFilterSetGreen
+foreign import ccall "static Imlib2.h imlib_filter_set_green" imlibFilterSetGreen :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+filterSetGreen xoff yoff a r g b = imlibFilterSetGreen (fromIntegral xoff) (fromIntegral yoff) (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_set_blue" imlibFilterSetBlue :: Int -> Int -> Int -> Int -> Int -> Int -> IO ()
-filterSetBlue = imlibFilterSetBlue
+foreign import ccall "static Imlib2.h imlib_filter_set_blue" imlibFilterSetBlue :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO ()
+filterSetBlue xoff yoff a r g b = imlibFilterSetBlue (fromIntegral xoff) (fromIntegral yoff) (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_constants(int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_constants" imlibFilterConstants :: Int -> Int -> Int -> Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_filter_constants" imlibFilterConstants :: CInt -> CInt -> CInt -> CInt -> IO ()
 filterConstants :: Int -> Int -> Int -> Int -> IO ()
-filterConstants = imlibFilterConstants
+filterConstants a r g b = imlibFilterConstants (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 --void imlib_filter_divisors(int a, int r, int g, int b);
-foreign import ccall "static Imlib2.h imlib_filter_divisors" imlibFilterDivisors :: Int -> Int -> Int -> Int -> IO ()
+foreign import ccall "static Imlib2.h imlib_filter_divisors" imlibFilterDivisors :: CInt -> CInt -> CInt -> CInt -> IO ()
 filterDivisors :: Int -> Int -> Int -> Int -> IO ()
-filterDivisors = imlibFilterDivisors
+filterDivisors a r g b = imlibFilterDivisors (fromIntegral a) (fromIntegral r) (fromIntegral g) (fromIntegral b)
 
 
diff --git a/Imlib.cabal b/Imlib.cabal
--- a/Imlib.cabal
+++ b/Imlib.cabal
@@ -1,15 +1,14 @@
 Name:                Imlib
-Version:             0.1.1
+Version:             0.1.2
 Description:         Haskell binding for Imlib 2
 Category:            Graphics
 License:             BSD3
 License-file:        LICENSE
 Author:              Cale Gibbard
-Maintainer:          cgibbard@gmail.com
+Maintainer:          Andreas Raster <lazor@affenbande.org>
 Build-Depends:       base, array, X11
 Build-Type:          Simple
 Exposed-Modules:     Graphics.Imlib
 Extra-Libraries:     Imlib2
 Extra-Source-Files:  examples/value2alpha.hs examples/circle-inversion.hs
-ghc-options:         -O2 -optl-Wl,-s
 ghc-prof-options:    -prof -auto-all
