module GEGL.Process
( gegl_node_process
, gegl_node_blit
) where
import Data.Bits
import Foreign.Marshal (free)
import Foreign.Marshal.Utils (new)
import Foreign.Ptr (Ptr)
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.C.Types (CInt(..), CDouble(..))
import GEGL.Enums (GeglBlitFlag)
import qualified GEGL.FFI.Process as FFI
import GEGL.FFI.Node (GeglNode(..))
import GEGL.FFI.Rectangle (GeglRectangle)
import BABL.FFI.Format (BablFormatPtr(..))
gegl_node_process
:: GeglNode
-> IO ()
gegl_node_process (GeglNode fnode) = withForeignPtr fnode (\node ->
FFI.c_gegl_node_process node)
gegl_node_blit
:: GeglNode
-> Double
-> GeglRectangle
-> BablFormatPtr
-> Ptr a
-> Int
-> [GeglBlitFlag]
-> IO ()
gegl_node_blit (GeglNode fnode) scale rect (BablFormatPtr babl) buf stride flags = do
crect <- new rect
let cscale = CDouble scale
cstride = CInt (fromIntegral stride)
cflags = CInt $ fromIntegral $
foldl (\acc arg -> acc .|. fromEnum arg) 0 flags
withForeignPtr fnode (\node ->
FFI.c_gegl_node_blit node cscale crect babl buf cstride cflags)
free crect