{-# 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 filename =
  withCAString filename $ \filenamePtr ->
  cairo_image_surface_create_from_png filenamePtr
  >>= mkSurface

surfaceWriteToPNG :: Surface -> FilePath -> IO (Status)
surfaceWriteToPNG a1 a2 =
  withSurface a1 $ \a1' -> 
  withCAString a2 $ \a2' -> 
  surfaceWriteToPNG'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  return (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)))