module Graphics.X11.Xlib.Image(
Image,
createImage,
putImage,
destroyImage,
getImage,
xGetPixel,
getPixel
) where
import Graphics.X11.Types
import Graphics.X11.Xlib.Types
import Foreign (Ptr, throwIfNull)
import Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)
createImage :: Display -> Visual -> CInt -> ImageFormat -> CInt -> Ptr CChar -> Dimension -> Dimension -> CInt -> CInt -> IO Image
createImage :: Display
-> Visual
-> CInt
-> CInt
-> CInt
-> Ptr CChar
-> Dimension
-> Dimension
-> CInt
-> CInt
-> IO Image
createImage display :: Display
display vis :: Visual
vis depth :: CInt
depth format :: CInt
format offset :: CInt
offset dat :: Ptr CChar
dat width :: Dimension
width height :: Dimension
height bitmap_pad :: CInt
bitmap_pad bytes_per_line :: CInt
bytes_per_line = do
Ptr Image
image <- String -> IO (Ptr Image) -> IO (Ptr Image)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
throwIfNull "createImage" (Display
-> Visual
-> CInt
-> CInt
-> CInt
-> Ptr CChar
-> Dimension
-> Dimension
-> CInt
-> CInt
-> IO (Ptr Image)
xCreateImage Display
display Visual
vis CInt
depth CInt
format CInt
offset Ptr CChar
dat Dimension
width Dimension
height CInt
bitmap_pad CInt
bytes_per_line)
Image -> IO Image
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Image -> Image
Image Ptr Image
image)
foreign import ccall unsafe "HsXlib.h XCreateImage"
xCreateImage :: Display -> Visual -> CInt -> ImageFormat -> CInt ->
Ptr CChar -> Dimension -> Dimension -> CInt -> CInt -> IO (Ptr Image)
foreign import ccall unsafe "HsXlib.h XPutImage"
putImage :: Display -> Drawable -> GC -> Image ->
Position -> Position -> Position -> Position -> Dimension -> Dimension -> IO ()
foreign import ccall unsafe "HsXlib.h XDestroyImage"
destroyImage :: Image -> IO ()
getImage :: Display -> Drawable -> CInt -> CInt -> CUInt -> CUInt -> CULong -> ImageFormat -> IO Image
getImage :: Display
-> Dimension
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CULong
-> CInt
-> IO Image
getImage display :: Display
display d :: Dimension
d x :: CInt
x y :: CInt
y width :: CUInt
width height :: CUInt
height plane_mask :: CULong
plane_mask format :: CInt
format = do
Ptr Image
image <- String -> IO (Ptr Image) -> IO (Ptr Image)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
throwIfNull "getImage" (Display
-> Dimension
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CULong
-> CInt
-> IO (Ptr Image)
xGetImage Display
display Dimension
d CInt
x CInt
y CUInt
width CUInt
height CULong
plane_mask CInt
format)
Image -> IO Image
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Image -> Image
Image Ptr Image
image)
foreign import ccall unsafe "HsXlib.h XGetImage"
xGetImage :: Display -> Drawable -> CInt -> CInt -> CUInt -> CUInt -> CULong -> ImageFormat -> IO (Ptr Image)
foreign import ccall unsafe "HsXlib.h XGetPixel"
xGetPixel :: Image -> CInt -> CInt -> IO CULong
getPixel :: Image -> CInt -> CInt -> CULong
getPixel :: Image -> CInt -> CInt -> CULong
getPixel i :: Image
i x :: CInt
x y :: CInt
y = IO CULong -> CULong
forall a. IO a -> a
unsafePerformIO (Image -> CInt -> CInt -> IO CULong
xGetPixel Image
i CInt
x CInt
y)