    {-# LINE 2 "./Graphics/Rendering/Cairo/Internal/Surfaces/PNG.chs" #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module : Graphics.Rendering.Cairo.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 Graphics.Rendering.Cairo.Internal.Surfaces.PNG where

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

    import Foreign
    import Foreign.C

    {-# LINE 23 "./Graphics/Rendering/Cairo/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 (Ptr Surface)
    cairo_image_surface_create_from_png CString
    filenamePtr
      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 -> IO Surface
    mkSurface

    surfaceWriteToPNG :: Surface -> FilePath -> IO (Status)
    surfaceWriteToPNG :: Surface -> FilePath -> IO Status
    surfaceWriteToPNG Surface
    a1 FilePath
    a2 =
      Surface -> (Ptr Surface -> IO Status) -> IO Status
    forall {b}. Surface -> (Ptr Surface -> IO b) -> IO b
    withSurface Surface
    a1 ((Ptr Surface -> IO Status) -> IO Status)
    -> (Ptr Surface -> IO Status) -> IO Status
    forall a b. (a -> b) -> a -> b
    $ \Ptr Surface
    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' ->
      Ptr Surface -> CString -> IO CInt
    surfaceWriteToPNG'_ Ptr Surface
    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 33 "./Graphics/Rendering/Cairo/Internal/Surfaces/PNG.chs" #-}

    foreign import ccall unsafe "cairo_image_surface_create_from_png"
      cairo_image_surface_create_from_png :: ((Ptr CChar) -> (IO (Ptr Surface)))

    foreign import ccall safe "cairo_surface_write_to_png"
      surfaceWriteToPNG'_ :: ((Ptr Surface) -> ((Ptr CChar) -> (IO CInt)))