short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { ImFileType *type; if (ibuf == NULL) return (false); ibuf->flags = flags; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->save && type->ftype(type, ibuf)) { ImBuf *write_ibuf; short result = false; write_ibuf = prepare_write_imbuf(type, ibuf); result = type->save(write_ibuf, name, flags); if (write_ibuf != ibuf) IMB_freeImBuf(write_ibuf); return result; } } fprintf(stderr, "Couldn't save picture.\n"); return false; }
short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { ImFileType *type; if(ibuf == NULL) return (FALSE); ibuf->flags = flags; for(type=IMB_FILE_TYPES; type->is_a; type++) { if(type->save && type->ftype(type, ibuf)) { if(!(type->flag & IM_FTYPE_FLOAT)) { if(ibuf->rect==NULL && ibuf->rect_float) IMB_rect_from_float(ibuf); } return type->save(ibuf, name, flags); } } fprintf(stderr, "Couldn't save picture.\n"); return FALSE; }
static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect) { ImFileType *type; unsigned char *mem; size_t size; if (file == -1) return; size = BLI_file_descriptor_size(file); mem = mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0); if (mem == (unsigned char *) -1) { fprintf(stderr, "Couldn't get memory mapping for %s\n", ibuf->cachename); return; } for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->load_tile && type->ftype(type, ibuf)) type->load_tile(ibuf, mem, size, tx, ty, rect); if (munmap(mem, size)) fprintf(stderr, "Couldn't unmap memory for %s.\n", ibuf->cachename); }