-- GENERATED by C->Haskell Compiler, version 0.28.6 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 a1 a2 a3 a4 a5 =
  let {a1' = id a1} in
  let {a2' = cFromEnum a2} in
  let {a3' = fromIntegral a3} in
  let {a4' = fromIntegral a4} in
  let {a5' = fromIntegral a5} in
  imageSurfaceCreateForData'_ a1' a2' a3' a4' a5' >>= \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)))