3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
35 #include "BLI_blenlib.h"
38 #include "imbuf_patch.h"
40 #include "IMB_imbuf_types.h"
41 #include "IMB_imbuf.h"
43 #include "IMB_allocimbuf.h"
45 #include "IMB_targa.h"
50 #include "IMB_amiga.h"
55 #include "IMB_bitplanes.h"
56 #include "IMB_divers.h"
58 short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags)
60 short ok=TRUE,delpl=FALSE;
63 if (ibuf==0) return (FALSE);
66 /* Put formats that take a filename here */
68 if(imb_savejpeg(ibuf, naam, flags)) return (0);
72 return imb_savepng(ibuf,naam,flags);
75 return imb_savebmp(ibuf,naam,flags);
78 return imb_savetarga(ibuf,naam,flags);
81 return imb_saveiris(ibuf,naam,flags);
84 file = open(naam, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
85 if (file < 0) return (FALSE);
93 /* Put formats that take a filehandle here */
95 ok = imb_start_iff(ibuf,file);
99 if ((flags & IB_cmap) == 0) {
101 if (ok) ok = imb_converttoham(ibuf);
102 }else if (ibuf->cmap){
103 if (ok) ok = IMB_converttocmap(ibuf);
107 if (ibuf->planes==0){
109 ok=imb_addplanesImBuf(ibuf);
115 if (flags & IB_vert){
116 if (ok) ok = imb_encodebodyv(ibuf,file);
119 if (ok) ok = imb_encodebodyh(ibuf,file);
121 if (ok) ok = imb_update_iff(file,BODY);
122 }else if (IS_anim(ibuf)) {
123 if (ok) ok = imb_enc_anim(ibuf, file);
124 if (ok) ok = imb_update_iff(file, BODY);
129 fprintf(stderr,"Couldn't save picture.\n");
131 if (delpl) imb_freeplanesImBuf(ibuf);