-- 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/PNG.chs" #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  GI.Cairo.Render.Internal.Surfaces.PNG
-- Copyright   :  (c) Paolo Martini 2005
-- License     :  BSD-style (see cairo/COPYRIGHT)
--
-- Maintainer  :  p.martini@neuralnoise.com
-- Stability   :  experimental
-- Portability :  portable
--
-- Reading and writing PNG images.
-----------------------------------------------------------------------------



module GI.Cairo.Render.Internal.Surfaces.PNG where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp



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


import Foreign
import Foreign.C


{-# LINE 24 "./GI/Cairo/Render/Internal/Surfaces/PNG.chs" #-}



imageSurfaceCreateFromPNG :: FilePath -> IO Surface
imageSurfaceCreateFromPNG :: FilePath -> IO Surface
imageSurfaceCreateFromPNG FilePath
filename =
  FilePath -> (CString -> IO Surface) -> IO Surface
forall a. FilePath -> (CString -> IO a) -> IO a
withCAString FilePath
filename ((CString -> IO Surface) -> IO Surface)
-> (CString -> IO Surface) -> IO Surface
forall a b. (a -> b) -> a -> b
$ \CString
filenamePtr ->
  CString -> IO SurfacePtr
cairo_image_surface_create_from_png CString
filenamePtr
  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 -> IO Surface
mkSurface

surfaceWriteToPNG :: (Surface) -> (FilePath) -> IO ((Status))
surfaceWriteToPNG :: Surface -> FilePath -> IO Status
surfaceWriteToPNG Surface
a1 FilePath
a2 =
  Surface -> (SurfacePtr -> IO Status) -> IO Status
forall {b}. Surface -> (SurfacePtr -> IO b) -> IO b
withSurface Surface
a1 ((SurfacePtr -> IO Status) -> IO Status)
-> (SurfacePtr -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \SurfacePtr
a1' -> 
  FilePath -> (CString -> IO Status) -> IO Status
forall a. FilePath -> (CString -> IO a) -> IO a
withCAString FilePath
a2 ((CString -> IO Status) -> IO Status)
-> (CString -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \CString
a2' -> 
  SurfacePtr -> CString -> IO CInt
surfaceWriteToPNG'_ SurfacePtr
a1' CString
a2' IO CInt -> (CInt -> IO Status) -> IO Status
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
  let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
  Status -> IO Status
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')

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



foreign import ccall unsafe "GI/Cairo/Render/Internal/Surfaces/PNG.chs.h cairo_image_surface_create_from_png"
  cairo_image_surface_create_from_png :: ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (SurfacePtr)))

foreign import ccall safe "GI/Cairo/Render/Internal/Surfaces/PNG.chs.h cairo_surface_write_to_png"
  surfaceWriteToPNG'_ :: ((SurfacePtr) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO C2HSImp.CInt)))