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 Visual
vis CInt
depth CInt
format CInt
offset Ptr CChar
dat Dimension
width Dimension
height CInt
bitmap_pad 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 String
"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
-> Drawable
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CULong
-> CInt
-> IO Image
getImage Display
display Drawable
d CInt
x CInt
y CUInt
width CUInt
height CULong
plane_mask CInt
format = do
Ptr Image
image <- String -> IO (Ptr Image) -> IO (Ptr Image)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
throwIfNull String
"getImage" (Display
-> Drawable
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CULong
-> CInt
-> IO (Ptr Image)
xGetImage Display
display Drawable
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 Image
i CInt
x CInt
y = IO CULong -> CULong
forall a. IO a -> a
unsafePerformIO (Image -> CInt -> CInt -> IO CULong
xGetPixel Image
i CInt
x CInt
y)