123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475(*
* This file is part of Imagelib.
*
* Imagelib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Imabelib 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Imabelib. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2014 Rodolphe Lepigre.
*)openStdlibopenImageUtilopenImageletxcf_signature="gimp xcf "typexcf_header_data={version:int;image_size:int*int;colour_type:int}moduleReadXCF:ReadImage=structletextensions=["xcf"]letversion_nums=matchswith|"file\000"->0|"v001\000"->1|"v002\000"->2|_->raise(Corrupted_image"Unknown version number...")letread_headerich=letmagic=get_bytesich9inletversion=get_bytesich5inletwidth=get_bytesich4inletheight=get_bytesich4inletbase_type=get_bytesich4inifmagic<>xcf_signaturethenraise(Corrupted_image"Corrupted header...");letw=int_of_str4widthinleth=int_of_str4heightinletct=int_of_str4base_typeinifct<0||ct>2thenraise(Corrupted_image"Unknown color type...");{version=version_numversion;image_size=w,h;colour_type=ct}(* Read the size of a XCF image.
* Arguments:
* - fn : filename.
* Returns a couble (width, height).
* Note: the image is not checked for inconsistency, only the signature and
* header are checked.
*)letsizeich=lethdr=read_headerichinclose_chunk_readerich;hdr.image_sizeletparsefile_=raise(Not_yet_implemented"ImageXCF.openfile")(* TODO *)endincludeReadXCF