Blender V4.3
writeimage.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cerrno>
10#include <cstdio>
11#include <cstdlib>
12
13#include "BLI_path_utils.hh" /* For assertions. */
14#include "BLI_utildefines.h"
15
17#include "IMB_filetype.hh"
18#include "IMB_imbuf.hh"
19#include "IMB_imbuf_types.hh"
20
21bool IMB_saveiff(ImBuf *ibuf, const char *filepath, int flags)
22{
23 errno = 0;
24
25 BLI_assert(!BLI_path_is_rel(filepath));
26
27 if (ibuf == nullptr) {
28 return false;
29 }
30 ibuf->flags = flags;
31
32 const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
33 if (type == nullptr || type->save == nullptr) {
34 fprintf(stderr, "Couldn't save picture.\n");
35 return false;
36 }
37
38 /* If writing byte image from float buffer, create a byte buffer for writing.
39 *
40 * For color managed image writing, IMB_colormanagement_imbuf_for_write should
41 * have already created this byte buffer. This is a basic fallback for other
42 * cases where we do not have a specific desired output colorspace. */
43 if (!(type->flag & IM_FTYPE_FLOAT)) {
44 if (ibuf->byte_buffer.data == nullptr && ibuf->float_buffer.data) {
47 }
48 }
49
50 return type->save(ibuf, filepath, flags);
51}
#define BLI_assert(a)
Definition BLI_assert.h:50
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
@ COLOR_ROLE_DEFAULT_BYTE
#define IM_FTYPE_FLOAT
void IMB_rect_from_float(ImBuf *ibuf)
Definition divers.cc:694
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.cc:232
ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
bool IMB_saveiff(ImBuf *ibuf, const char *filepath, int flags)
Definition writeimage.cc:21