Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Show First 20 Lines • Show All 1,851 Lines • ▼ Show 20 Lines | if (ibuf) { | ||||
| /* we need renderresult for exr and rendered multiview */ | /* we need renderresult for exr and rendered multiview */ | ||||
| scene = CTX_data_scene(C); | scene = CTX_data_scene(C); | ||||
| rr = BKE_image_acquire_renderresult(scene, ima); | rr = BKE_image_acquire_renderresult(scene, ima); | ||||
| is_mono = rr ? BLI_listbase_count_ex(&rr->views, 2) < 2 : BLI_listbase_count_ex(&ima->views, 2) < 2; | is_mono = rr ? BLI_listbase_count_ex(&rr->views, 2) < 2 : BLI_listbase_count_ex(&ima->views, 2) < 2; | ||||
| /* error handling */ | /* error handling */ | ||||
| if (!rr) { | if (!rr) { | ||||
| if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) { | if (imf->imtype == R_IMF_IMTYPE_MULTILAYER || imf->views_format == R_IMF_VIEWS_MULTIVIEW) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image"); | BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image"); | ||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (imf->views_format == R_IMF_VIEWS_STEREO_3D) { | if (imf->views_format == R_IMF_VIEWS_STEREO_3D) { | ||||
| if (!BKE_image_is_stereo(ima)) { | if (!BKE_image_is_stereo(ima)) { | ||||
| BKE_reportf(op->reports, RPT_ERROR, "Did not write, the image doesn't have a \"%s\" and \"%s\" views", | BKE_reportf(op->reports, RPT_ERROR, "Did not write, the image doesn't have a \"%s\" and \"%s\" views", | ||||
| Show All 9 Lines | else { | ||||
| STEREO_LEFT_NAME, STEREO_RIGHT_NAME); | STEREO_LEFT_NAME, STEREO_RIGHT_NAME); | ||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| } | } | ||||
| BKE_imbuf_stamp_info(rr, ibuf); | BKE_imbuf_stamp_info(rr, ibuf); | ||||
| } | } | ||||
| /* fancy multiview OpenEXR */ | /* fancy multiview OpenEXR */ | ||||
| if ((imf->imtype == R_IMF_IMTYPE_MULTILAYER) && (imf->views_format == R_IMF_VIEWS_MULTIVIEW)) { | if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && | ||||
| ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, true, NULL); | (imf->imtype == R_IMF_IMTYPE_MULTILAYER || imf->imtype == R_IMF_IMTYPE_OPENEXR)) { | ||||
| /* save render result */ | |||||
| ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, sima->iuser.layer); | |||||
| save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); | save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); | ||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| } | } | ||||
| else if ((imf->imtype == R_IMF_IMTYPE_OPENEXR) && (imf->views_format == R_IMF_VIEWS_MULTIVIEW)) { | |||||
| /* treat special Openexr case separetely (this is the singlelayer multiview OpenEXR */ | |||||
| BKE_imbuf_write_prepare(ibuf, imf); | |||||
| ok = BKE_image_save_openexr_multiview(ima, ibuf, simopts->filepath, (IB_rect | IB_zbuf | IB_zbuffloat | IB_multiview)); | |||||
| ED_space_image_release_buffer(sima, ibuf, lock); | |||||
| } | |||||
| /* regular mono pipeline */ | /* regular mono pipeline */ | ||||
| else if (is_mono) { | else if (is_mono) { | ||||
| if (is_multilayer) { | if (is_multilayer) { | ||||
| ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, false, NULL); | ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1); | ||||
| } | } | ||||
| else { | else { | ||||
| colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf); | colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf); | ||||
| ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy); | ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy); | ||||
| save_imbuf_post(ibuf, colormanaged_ibuf); | save_imbuf_post(ibuf, colormanaged_ibuf); | ||||
| } | } | ||||
| save_image_post(op, ibuf, ima, ok, (is_multilayer ? true : save_copy), relbase, relative, do_newpath, simopts->filepath); | save_image_post(op, ibuf, ima, ok, (is_multilayer ? true : save_copy), relbase, relative, do_newpath, simopts->filepath); | ||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| Show All 11 Lines | else if (imf->views_format == R_IMF_VIEWS_INDIVIDUAL) { | ||||
| for (i = 0; i < totviews; i++) { | for (i = 0; i < totviews; i++) { | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| bool ok_view = false; | bool ok_view = false; | ||||
| const char *view = rr ? ((RenderView *) BLI_findlink(&rr->views, i))->name : | const char *view = rr ? ((RenderView *) BLI_findlink(&rr->views, i))->name : | ||||
| ((ImageView *) BLI_findlink(&ima->views, i))->name; | ((ImageView *) BLI_findlink(&ima->views, i))->name; | ||||
| if (is_multilayer) { | if (is_multilayer) { | ||||
| BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath); | BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath); | ||||
| ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, false, view); | ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, -1); | ||||
| save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); | save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); | ||||
| } | } | ||||
| else { | else { | ||||
| /* copy iuser to get the correct ibuf for this view */ | /* copy iuser to get the correct ibuf for this view */ | ||||
| ImageUser iuser = sima->iuser; | ImageUser iuser = sima->iuser; | ||||
| iuser.view = i; | iuser.view = i; | ||||
| iuser.flag &= ~IMA_SHOW_STEREO; | iuser.flag &= ~IMA_SHOW_STEREO; | ||||
| Show All 18 Lines | else if (imf->views_format == R_IMF_VIEWS_INDIVIDUAL) { | ||||
| if (is_multilayer) { | if (is_multilayer) { | ||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| } | } | ||||
| } | } | ||||
| /* stereo (multiview) images */ | /* stereo (multiview) images */ | ||||
| else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) { | else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) { | ||||
| if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) { | if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) { | ||||
| ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, false, NULL); | ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1); | ||||
| save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); | save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); | ||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| } | } | ||||
| else { | else { | ||||
| ImBuf *ibuf_stereo[2] = {NULL}; | ImBuf *ibuf_stereo[2] = {NULL}; | ||||
| unsigned char planes = ibuf->planes; | unsigned char planes = ibuf->planes; | ||||
| const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | ||||
| ▲ Show 20 Lines • Show All 1,758 Lines • Show Last 20 Lines | |||||