    -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
    -- Edit the ORIGNAL .chs file instead!

    {-# LINE 1 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}
    {-# LANGUAGE CPP #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  GI.Cairo.Render.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 GI.Cairo.Render.Internal.Surfaces.Image where
    import qualified Foreign.C.Types as C2HSImp
    import qualified Foreign.Ptr as C2HSImp
    import qualified System.IO.Unsafe as C2HSImp

    import GI.Cairo.Render.Types
    {-# LINE 19 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    import Foreign
    import Foreign.C

    {-# LINE 24 "./GI/Cairo/Render/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, Num b) => a -> b
    fromIntegral Int
    a3} in
      let {a4' :: CInt
    a4' = Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    a4} in
      let {a5' :: CInt
    a5' = Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    a5} in
      Ptr CUChar -> CInt -> CInt -> CInt -> CInt -> IO SurfacePtr
    imageSurfaceCreateForData'_ Ptr CUChar
    a1' CInt
    a2' CInt
    a3' CInt
    a4' CInt
    a5' IO SurfacePtr -> (SurfacePtr -> 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
    >>= \SurfacePtr
    res ->
      mkSurface res >>= \res' ->
      return (res')

    {-# LINE 32 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    imageSurfaceCreate :: (Format) -> (Int) -> (Int) -> IO ((Surface))
    imageSurfaceCreate a1 a2 a3 =
      let {a1' = cFromEnum a1} in
      let {a2' = fromIntegral a2} in
      let {a3' = fromIntegral a3} in
      imageSurfaceCreate'_ a1' a2' a3' >>= \res ->
      mkSurface res >>= \res' ->
      return (res')

    {-# LINE 34 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    imageSurfaceGetWidth :: (Surface) -> IO ((Int))
    imageSurfaceGetWidth a1 =
      withSurface a1 $ \a1' ->
      imageSurfaceGetWidth'_ a1' >>= \res ->
      let {res' = fromIntegral res} in
      return (res')

    {-# LINE 35 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    imageSurfaceGetHeight :: (Surface) -> IO ((Int))
    imageSurfaceGetHeight a1 =
      withSurface a1 $ \a1' ->
      imageSurfaceGetHeight'_ a1' >>= \res ->
      let {res' = fromIntegral res} in
      return (res')

    {-# LINE 37 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    imageSurfaceGetStride :: (Surface) -> IO ((Int))
    imageSurfaceGetStride a1 =
      withSurface a1 $ \a1' ->
      imageSurfaceGetStride'_ a1' >>= \res ->
      let {res' = fromIntegral res} in
      return (res')

    {-# LINE 38 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    imageSurfaceGetFormat :: (Surface) -> IO ((Format))
    imageSurfaceGetFormat a1 =
      withSurface a1 $ \a1' ->
      imageSurfaceGetFormat'_ a1' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 39 "./GI/Cairo/Render/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 41 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    formatStrideForWidth :: (Format) -> (Int) -> (Int)
    formatStrideForWidth a1 a2 =
      C2HSImp.unsafePerformIO $
      let {a1' = cFromEnum a1} in
      let {a2' = fromIntegral a2} in
      formatStrideForWidth'_ a1' a2' >>= \res ->
      let {res' = fromIntegral res} in
      return (res')

    {-# LINE 44 "./GI/Cairo/Render/Internal/Surfaces/Image.chs" #-}

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_create_for_data"
      imageSurfaceCreateForData'_ :: ((C2HSImp.Ptr C2HSImp.CUChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (SurfacePtr)))))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_create"
      imageSurfaceCreate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (SurfacePtr)))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_get_width"
      imageSurfaceGetWidth'_ :: ((SurfacePtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_get_height"
      imageSurfaceGetHeight'_ :: ((SurfacePtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_get_stride"
      imageSurfaceGetStride'_ :: ((SurfacePtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_get_format"
      imageSurfaceGetFormat'_ :: ((SurfacePtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_image_surface_get_data"
      imageSurfaceGetData'_ :: ((SurfacePtr) -> (IO (C2HSImp.Ptr C2HSImp.CUChar)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/Image.chs.h cairo_format_stride_for_width"
      formatStrideForWidth'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))