{-# 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 a1 a2 a3 a4 a5 =
  let {a1' = id a1} in 
  let {a2' = cFromEnum a2} in 
  let {a3' = cIntConv a3} in 
  let {a4' = cIntConv a4} in 
  let {a5' = cIntConv a5} in 
  imageSurfaceCreateForData'_ a1' a2' a3' a4' a5' >>= \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))