Blender  V3.3
writeimage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <errno.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #include "BLI_path_util.h"
13 #include "BLI_utildefines.h"
14 
15 #include "IMB_filetype.h"
16 #include "IMB_imbuf.h"
17 #include "IMB_imbuf_types.h"
18 
19 #include "IMB_colormanagement.h"
21 
22 bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
23 {
24  errno = 0;
25 
26  BLI_assert(!BLI_path_is_rel(filepath));
27 
28  if (ibuf == NULL) {
29  return false;
30  }
31  ibuf->flags = flags;
32 
34  if (type == NULL || type->save == NULL) {
35  fprintf(stderr, "Couldn't save picture.\n");
36  return false;
37  }
38 
39  /* If writing byte image from float buffer, create a byte buffer for writing.
40  *
41  * For color managed image writing, IMB_colormanagement_imbuf_for_write should
42  * have already created this byte buffer. This is a basic fallback for other
43  * cases where we do not have a specific desired output colorspace. */
44  if (!(type->flag & IM_FTYPE_FLOAT)) {
45  if (ibuf->rect == NULL && ibuf->rect_float) {
47  IMB_rect_from_float(ibuf);
48  }
49  }
50 
51  return type->save(ibuf, filepath, flags);
52 }
#define BLI_assert(a)
Definition: BLI_assert.h:46
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:347
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
@ COLOR_ROLE_DEFAULT_BYTE
#define IM_FTYPE_FLOAT
Definition: IMB_filetype.h:17
void IMB_rect_from_float(struct ImBuf *ibuf)
Definition: divers.c:696
Contains defines and structs used throughout the imbuf module.
ColorSpace * colormanage_colorspace_get_roled(int role)
const ImFileType * IMB_file_type_from_ibuf(const ImBuf *ibuf)
Definition: filetype.c:243
struct ColorSpace * rect_colorspace
unsigned int * rect
float * rect_float
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: writeimage.c:22