81 const bool guess_path,
82 const bool save_as_render)
86 if (iuser ==
nullptr) {
92 memset(opts, 0,
sizeof(*opts));
105 bool is_depth_set =
false;
153 if (is_depth_set ==
false) {
163 if (guess_path && opts->
filepath[0] == 0) {
164 const bool is_prev_save = !
STREQ(
G.ima,
"//");
194 return (ibuf !=
nullptr);
214 &
image->colorspace_settings);
226 if (linear_float_output && !is_linear) {
230 else if (!linear_float_output && is_linear) {
247 const char *filepath,
267 const char *filepath,
268 bool *r_colorspace_changed)
324 *r_colorspace_changed =
true;
331 if (colormanaged_ibuf != ibuf) {
353 bool *r_colorspace_changed)
360 if (ibuf ==
nullptr || (ibuf->
rect ==
nullptr && ibuf->
rect_float ==
nullptr)) {
365 ImBuf *colormanaged_ibuf =
nullptr;
396 const int layer = (iuser && !is_multilayer) ? iuser->
layer : -1;
411 R
"(Did not write, the image doesn't have a "%s" and "%s" views)",
424 R
"(Did not write, the image doesn't have a "%s" and "%s" views)",
439 reports, rr, opts->
filepath, imf, save_as_render,
nullptr, layer);
447 reports, rr, opts->
filepath, imf, save_as_render,
nullptr, layer);
459 (is_exr_rr ?
true : save_copy),
461 r_colorspace_changed);
466 unsigned char planes = ibuf->
planes;
473 for (
int i = 0; i < totviews; i++) {
475 bool ok_view =
false;
482 reports, rr, filepath, imf, save_as_render,
view, layer);
483 image_save_post(reports, ima, ibuf, ok_view, opts,
true, filepath, r_colorspace_changed);
515 image_save_post(reports, ima, ibuf, ok_view, opts,
true, filepath, r_colorspace_changed);
529 reports, rr, opts->
filepath, imf, save_as_render,
nullptr, layer);
534 ImBuf *ibuf_stereo[2] = {
nullptr};
536 unsigned char planes = ibuf->
planes;
541 bool stereo_ok =
true;
543 for (
int i = 0; i < 2; i++) {
567 if (ibuf ==
nullptr) {
569 reports,
RPT_ERROR,
"Did not write, unexpected error when saving stereo image");
599 for (
int i = 0; i < 2; i++) {
617 if (iuser ==
nullptr) {
623 bool colorspace_changed =
false;
626 char *udim_pattern =
nullptr;
634 "When saving a tiled image, the path '%s' must contain a valid UDIM marker",
650 tile_opts.
filepath, udim_pattern, tile_format,
tile->tile_number);
666 if (colorspace_changed) {
682 if (imf ==
nullptr) {
692 tmp_output_rects.
append(output_rect);
704 const char *filepath,
706 const bool save_as_render,
717 if (!multi_layer && layer == -1) {
723 if (first_rview && (first_rview->
next || first_rview->
name[0])) {
738 const char *viewname = rview->name;
748 if (!multi_layer && layer != 0) {
752 float *output_rect = (save_as_render) ?
754 rview->rectf, rr->
rectx, rr->
recty, 4, imf, tmp_output_rects) :
757 for (
int a = 0;
a < 4;
a++) {
760 const char *chan_id =
"RGBA";
764 BLI_strncpy(layname,
"Composite",
sizeof(layname));
767 passname[0] = chan_id[
a];
773 exrhandle, layname, passname, viewname, 4, 4 * rr->
rectx, output_rect +
a, half_float);
776 if (write_z && rview->rectz) {
777 const char *layname = (multi_layer) ?
"Composite" :
"";
787 if (!multi_layer && nr != layer) {
801 const char *viewname = rp->view;
812 const bool pass_RGBA = (
STR_ELEM(rp->chan_id,
"RGB",
"RGBA",
"R",
"G",
"B",
"A"));
813 const bool pass_half_float = half_float && pass_RGBA;
817 (save_as_render && pass_RGBA) ?
819 rp->rect, rr->
rectx, rr->
recty, rp->channels, imf, tmp_output_rects) :
822 for (
int a = 0;
a < rp->channels;
a++) {
832 passname[0] = rp->chan_id[
a];
842 rp->channels * rr->
rectx,
853 int compress = (imf ? imf->
exr_codec : 0);
862 reports,
RPT_ERROR,
"Error writing render result, %s (see console)", strerror(errno));
865 for (
float *rect : tmp_output_rects) {
879 printf(
"Saved: '%s'\n", name);
914 const char *filepath_basis)
926 const bool is_exr_rr =
ELEM(
940 rv = rv->next, view_id++) {
943 STRNCPY(filepath, filepath_basis);
959 filepath[strlen(filepath) - 4] = 0;
968 reports,
scene, rr, ibuf, filepath, &image_format, stamp);
979 reports,
scene, rr, ibuf, filepath, &image_format, stamp);
990 STRNCPY(filepath, filepath_basis);
993 printf(
"Stereo 3D not supported for MultiLayer image: %s\n", filepath);
996 ImBuf *ibuf_arr[3] = {
nullptr};
1000 for (i = 0; i < 2; i++) {
1009 reports,
scene, rr, ibuf_arr[2], filepath, &image_format, stamp);
1017 filepath[strlen(filepath) - 4] = 0;
1021 ibuf_arr[2]->
planes = 24;
1024 reports,
scene, rr, ibuf_arr[2], filepath, &image_format, stamp);
1028 for (i = 0; i < 3; i++) {
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
int BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf, bool save_copy)
struct RenderResult * BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima)
void BKE_image_set_filepath_from_tile_number(char *filepath, const char *pattern, eUDIM_TILE_FORMAT tile_format, int tile_number)
bool BKE_imbuf_alpha_test(struct ImBuf *ibuf)
int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
bool BKE_image_is_multiview(const struct Image *ima)
void BKE_imbuf_stamp_info(const struct RenderResult *rr, struct ImBuf *ibuf)
struct RenderPass * BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser)
bool BKE_image_is_stereo(const struct Image *ima)
#define IMA_SIGNAL_COLORMANAGE
void BKE_image_multiview_index(const struct Image *ima, struct ImageUser *iuser)
void BKE_image_user_file_path_ex(const struct Main *bmain, const struct ImageUser *iuser, const struct Image *ima, char *path, const bool resolve_udim, const bool resolve_multiview)
int BKE_imbuf_write_stamp(const struct Scene *scene, const struct RenderResult *rr, struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf)
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
void BKE_image_release_renderresult(struct Scene *scene, struct Image *ima)
char * BKE_image_get_tile_strformat(const char *filepath, eUDIM_TILE_FORMAT *r_tile_format)
void BKE_imageuser_default(struct ImageUser *iuser)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_scene_multiview_view_filepath_get(const struct RenderData *rd, const char *filepath, const char *view, char *r_filepath)
#define LISTBASE_FOREACH(type, var, list)
int BLI_listbase_count_at_most(const struct ListBase *listbase, int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findstringindex(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1)
bool BLI_make_existing_file(const char *name)
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL()
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
#define STRNCPY(dst, src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define STR_CONCAT(dst, len, suffix)
#define ID_BLEND_PATH(_bmain, _id)
#define RE_PASSNAME_COMBINED
#define R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE
#define R_IMF_IMTYPE_MULTILAYER
#define R_IMF_PLANES_RGBA
#define STEREO_RIGHT_NAME
#define R_IMF_FLAG_PREVIEW_JPG
#define R_IMF_IMTYPE_OPENEXR
#define R_IMF_IMTYPE_JPEG90
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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 const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct ImBuf * IMB_colormanagement_imbuf_for_write(struct ImBuf *ibuf, bool save_as_render, bool allocate_result, const struct ImageFormatData *image_format)
bool IMB_colormanagement_space_name_is_scene_linear(const char *name)
@ COLOR_ROLE_DEFAULT_FLOAT
@ COLOR_ROLE_DEFAULT_BYTE
@ COLOR_ROLE_SCENE_LINEAR
bool IMB_colormanagement_space_name_is_data(const char *name)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
void imb_freerectfloatImBuf(struct ImBuf *ibuf)
void IMB_freezbuffloatImBuf(struct ImBuf *ibuf)
struct ImBuf * IMB_stereo3d_ImBuf(const struct ImageFormatData *im_format, struct ImBuf *ibuf_left, struct ImBuf *ibuf_right)
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void imb_freerectImBuf(struct ImBuf *ibuf)
void IMB_freezbufImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
bool IMB_exr_begin_write(void *handle, const char *filepath, int width, int height, int compress, const struct StampData *stamp)
void IMB_exr_add_channel(void *handle, const char *layname, const char *passname, const char *view, int xstride, int ystride, float *rect, bool use_half_float)
void IMB_exr_add_view(void *handle, const char *name)
void IMB_exr_close(void *handle)
void IMB_exr_write_channels(void *handle)
void * IMB_exr_get_handle(void)
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
ColorManagedColorspaceSettings colorspace_settings
struct Stereo3dFormat * stereo3d_format
void append(const T &value)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
bool BKE_image_save(ReportList *reports, Main *bmain, Image *ima, ImageUser *iuser, const ImageSaveOptions *opts)
bool BKE_image_render_write(ReportList *reports, RenderResult *rr, const Scene *scene, const bool stamp, const char *filepath_basis)
static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf)
bool BKE_image_render_write_exr(ReportList *reports, const RenderResult *rr, const char *filepath, const ImageFormatData *imf, const bool save_as_render, const char *view, int layer)
static char imtype_best_depth(ImBuf *ibuf, const char imtype)
bool BKE_image_save_options_init(ImageSaveOptions *opts, Main *bmain, Scene *scene, Image *ima, ImageUser *iuser, const bool guess_path, const bool save_as_render)
static float * image_exr_from_scene_linear_to_output(float *rect, const int width, const int height, const int channels, const ImageFormatData *imf, Vector< float * > &tmp_output_rects)
static void image_save_post(ReportList *reports, Image *ima, ImBuf *ibuf, int ok, const ImageSaveOptions *opts, int save_copy, const char *filepath, bool *r_colorspace_changed)
static bool image_save_single(ReportList *reports, Image *ima, ImageUser *iuser, const ImageSaveOptions *opts, bool *r_colorspace_changed)
static void image_save_update_filepath(Image *ima, const char *filepath, const ImageSaveOptions *opts)
static void image_render_print_save_message(ReportList *reports, const char *name, int ok, int err)
void BKE_image_save_options_update(ImageSaveOptions *opts, const Image *image)
static int image_render_write_stamp_test(ReportList *reports, const Scene *scene, const RenderResult *rr, ImBuf *ibuf, const char *name, const ImageFormatData *imf, const bool stamp)
void BKE_image_save_options_free(ImageSaveOptions *opts)
ccl_global const KernelWorkTile * tile
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
bool RE_HasFloatPixels(const RenderResult *rr)
ImBuf * RE_render_result_rect_to_ibuf(RenderResult *rr, const ImageFormatData *imf, const float dither, const int view_id)
void RE_render_result_full_channel_name(char *fullname, const char *layname, const char *passname, const char *viewname, const char *chan_id, const int channel)
ImbFormatOptions foptions
char name[IMB_FILENAME_SIZE]
struct ImageFormatData im_format
struct ImageFormatData im_format
struct StampData * stamp_data