--
--	rasterio: libpng interface
--	Copyright (C) 2007, 2009  Adam Sampson <ats@offog.org>
--
--	This library is free software; you can redistribute it and/or
--	modify it under the terms of the GNU Lesser General Public
--	License as published by the Free Software Foundation, either
--	version 2 of the License, or (at your option) any later version.
--
--	This library is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--	Lesser General Public License for more details.
--
--	You should have received a copy of the GNU Lesser General Public
--	License along with this library.  If not, see
--	<http://www.gnu.org/licenses/>.
--

--** @module rasterio

#INCLUDE "raster.module"

--{{{  externals
#PRAGMA EXTERNAL "PROC C.read.raster.png.1 (VAL []BYTE filename, RESULT INT height, width, magic) = 0"
#PRAGMA EXTERNAL "PROC C.read.raster.png.2 (VAL INT magic, [][]INT raster, INT rc) = 0"
#PRAGMA EXTERNAL "PROC C.write.raster.png (VAL []BYTE filename, VAL [][]INT raster, RESULT INT rc) = 0"
--}}}

--{{{  PROC read.raster.png
--* Load a PNG file as a raster.
PROC read.raster.png (VAL []BYTE filename, RESULT RASTER raster)
  INT height, width, magic, rc:
  SEQ
    C.read.raster.png.1 (filename, height, width, magic)
    raster := MOBILE [height][width]INT
    C.read.raster.png.2 (magic, raster, rc)
    ASSERT (rc = 0)
:
--}}}

--{{{  PROC write.raster.png
--* Write a raster out as a PNG file.
PROC write.raster.png (VAL []BYTE filename, VAL [][]INT raster)
  INT rc:
  SEQ
    C.write.raster.png (filename, raster, rc)
    ASSERT (rc = 0)
:
--}}}
