{-# LINE 2 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}
-----------------------------------------------------------------------------
-- |
-- Module : Graphics.Rendering.Cairo.Internal.Surfaces.Image
-- Copyright : (c) Paolo Martini 2005
-- License : BSD-style (see doc/COPYRIGHT)
--
-- Maintainer : p.martini@neuralnoise.com
-- Stability : experimental
-- Portability : portable
--
-- Rendering to memory buffers.
-----------------------------------------------------------------------------

module Graphics.Rendering.Cairo.Internal.Surfaces.Image where

import Graphics.Rendering.Cairo.Types
{-# LINE 18 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

import Foreign
import Foreign.C


{-# LINE 23 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

imageSurfaceCreateForData :: Ptr CUChar -> Format -> Int -> Int -> Int -> IO (Surface)
imageSurfaceCreateForData :: Ptr CUChar -> Format -> Int -> Int -> Int -> IO Surface
imageSurfaceCreateForData Ptr CUChar
a1 Format
a2 Int
a3 Int
a4 Int
a5 =
  let {a1' :: Ptr CUChar
a1' = Ptr CUChar -> Ptr CUChar
forall a. a -> a
id Ptr CUChar
a1} in 
  let {a2' :: CInt
a2' = Format -> CInt
forall e i. (Enum e, Integral i) => e -> i
cFromEnum Format
a2} in 
  let {a3' :: CInt
a3' = Int -> CInt
forall a b. (Integral a, Integral b) => a -> b
cIntConv Int
a3} in 
  let {a4' :: CInt
a4' = Int -> CInt
forall a b. (Integral a, Integral b) => a -> b
cIntConv Int
a4} in 
  let {a5' :: CInt
a5' = Int -> CInt
forall a b. (Integral a, Integral b) => a -> b
cIntConv Int
a5} in 
  Ptr CUChar -> CInt -> CInt -> CInt -> CInt -> IO (Ptr Surface)
imageSurfaceCreateForData'_ Ptr CUChar
a1' CInt
a2' CInt
a3' CInt
a4' CInt
a5' IO (Ptr Surface) -> (Ptr Surface -> IO Surface) -> IO Surface
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr Surface
res ->
  mkSurface res >>= \res' ->
  return (res')
{-# LINE 31 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

imageSurfaceCreate :: Format -> Int -> Int -> IO (Surface)
imageSurfaceCreate a1 a2 a3 =
  let {a1' = cFromEnum a1} in 
  let {a2' = cIntConv a2} in 
  let {a3' = cIntConv a3} in 
  imageSurfaceCreate'_ a1' a2' a3' >>= \res ->
  mkSurface res >>= \res' ->
  return (res')
{-# LINE 33 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}
imageSurfaceGetWidth :: Surface -> IO (Int)
imageSurfaceGetWidth a1 =
  withSurface a1 $ \a1' -> 
  imageSurfaceGetWidth'_ a1' >>= \res ->
  let {res' = cIntConv res} in
  return (res')
{-# LINE 34 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}
imageSurfaceGetHeight :: Surface -> IO (Int)
imageSurfaceGetHeight a1 =
  withSurface a1 $ \a1' -> 
  imageSurfaceGetHeight'_ a1' >>= \res ->
  let {res' = cIntConv res} in
  return (res')
{-# LINE 35 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

imageSurfaceGetStride :: Surface -> IO (Int)
imageSurfaceGetStride a1 =
  withSurface a1 $ \a1' -> 
  imageSurfaceGetStride'_ a1' >>= \res ->
  let {res' = cIntConv res} in
  return (res')
{-# LINE 37 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}
imageSurfaceGetFormat :: Surface -> IO (Format)
imageSurfaceGetFormat a1 =
  withSurface a1 $ \a1' -> 
  imageSurfaceGetFormat'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  return (res')
{-# LINE 38 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}
imageSurfaceGetData :: Surface -> IO ((Ptr CUChar))
imageSurfaceGetData a1 =
  withSurface a1 $ \a1' -> 
  imageSurfaceGetData'_ a1' >>= \res ->
  let {res' = id res} in
  return (res')
{-# LINE 39 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

formatStrideForWidth :: Format -> Int -> Int
formatStrideForWidth a1 a2 =
  let {a1' = cFromEnum a1} in 
  let {a2' = cIntConv a2} in 
  let {res = formatStrideForWidth'_ a1' a2'} in
  let {res' = cIntConv res} in
  (res')
{-# LINE 41 "./Graphics/Rendering/Cairo/Internal/Surfaces/Image.chs" #-}

foreign import ccall safe "cairo_image_surface_create_for_data"
  imageSurfaceCreateForData'_ :: ((Ptr CUChar) -> (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr Surface)))))))

foreign import ccall safe "cairo_image_surface_create"
  imageSurfaceCreate'_ :: (CInt -> (CInt -> (CInt -> (IO (Ptr Surface)))))

foreign import ccall safe "cairo_image_surface_get_width"
  imageSurfaceGetWidth'_ :: ((Ptr Surface) -> (IO CInt))

foreign import ccall safe "cairo_image_surface_get_height"
  imageSurfaceGetHeight'_ :: ((Ptr Surface) -> (IO CInt))

foreign import ccall safe "cairo_image_surface_get_stride"
  imageSurfaceGetStride'_ :: ((Ptr Surface) -> (IO CInt))

foreign import ccall safe "cairo_image_surface_get_format"
  imageSurfaceGetFormat'_ :: ((Ptr Surface) -> (IO CInt))

foreign import ccall safe "cairo_image_surface_get_data"
  imageSurfaceGetData'_ :: ((Ptr Surface) -> (IO (Ptr CUChar)))

foreign import ccall safe "cairo_format_stride_for_width"
  formatStrideForWidth'_ :: (CInt -> (CInt -> CInt))