~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/imbuf/intern/targa.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 * Contributor(s): none yet.
28
28
 *
29
29
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
30
 
 * $Id: targa.c,v 1.7 2004/01/22 12:59:46 ton Exp $
 
30
 * $Id: targa.c,v 1.12 2005/03/19 21:08:10 zuster Exp $
31
31
 */
32
32
 
33
 
#ifdef HAVE_CONFIG_H
34
 
#include <config.h>
35
 
#endif
36
 
 
37
33
#ifdef WIN32
38
 
#include "BLI_winstuff.h"
39
34
#include <io.h>
40
35
#endif
41
36
#include "BLI_blenlib.h"
242
237
}
243
238
 
244
239
 
245
 
short imb_savetarga(struct ImBuf * ibuf, int file, int flags)
 
240
short imb_savetarga(struct ImBuf * ibuf, char *name, int flags)
246
241
{
247
242
        char buf[20];
248
243
        FILE *fildes;
289
284
 
290
285
        if (flags & IB_ttob) buf[17] ^= 0x20;
291
286
 
292
 
        /* Don't forget to indicate that your 32 bit
293
 
         * targa uses 8 bits for the alpha channel! */
294
 
        if (ibuf->depth==32) {
295
 
           buf[17] |= 0x08;
296
 
        }
297
 
 
298
 
        if (write(file, buf, 18) != 18) return (0);
 
287
        /* Don't forget to indicate that your 32 bit
 
288
         * targa uses 8 bits for the alpha channel! */
 
289
        if (ibuf->depth==32) {
 
290
                buf[17] |= 0x08;
 
291
        }
 
292
        fildes = fopen(name,"wb");
 
293
        if (!fildes) return 0;
 
294
 
 
295
        if (fwrite(buf, 1, 18,fildes) != 18) return (0);
 
296
 
299
297
        if (ibuf->cmap){
300
298
                for (i = 0 ; i<ibuf->maxcol ; i++){
301
 
                        if (write(file,((uchar *)(ibuf->cmap + i)) + 1,3) != 3) return (0);
 
299
                        if (fwrite(((uchar *)(ibuf->cmap + i)) + 1,1,3,fildes) != 3) return (0);
302
300
                }
303
301
        }
304
 
        fildes = fdopen(file,"ab");
305
302
        
306
303
        if (ibuf->cmap && (flags & IB_cmap) == 0) IMB_converttocmap(ibuf);
307
304