/* called for reading temp files, and for external engines */ int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, const char *filepath) { RenderLayer *rl; RenderPass *rpass; void *exrhandle = IMB_exr_get_handle(); int rectx, recty; if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty) == 0) { printf("failed being read %s\n", filepath); IMB_exr_close(exrhandle); return 0; } if (rr == NULL || rectx != rr->rectx || recty != rr->recty) { if (rr) printf("error in reading render result: dimensions don't match\n"); else printf("error in reading render result: NULL result pointer\n"); IMB_exr_close(exrhandle); return 0; } for (rl = rr->layers.first; rl; rl = rl->next) { if (rl_single && rl_single != rl) continue; /* combined */ if (rl->rectf) { int a, xstride = 4; for (a = 0; a < xstride; a++) IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride * rectx, rl->rectf + a); } /* passes are allocated in sync */ for (rpass = rl->passes.first; rpass; rpass = rpass->next) { int a, xstride = rpass->channels; for (a = 0; a < xstride; a++) IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a), xstride, xstride * rectx, rpass->rect + a); BLI_strncpy(rpass->name, get_pass_name(rpass->passtype, -1), sizeof(rpass->name)); } } IMB_exr_read_channels(exrhandle); IMB_exr_close(exrhandle); return 1; }
static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart, const char *viewname) { RenderLayer *rlp, *rl; RenderPass *rpassp; int offs, partx, party; BLI_lock_thread(LOCK_IMAGE); for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) { rl = RE_GetRenderLayer(rr, rlp->name); /* should never happen but prevents crash if it does */ BLI_assert(rl); if (UNLIKELY(rl == NULL)) { continue; } if (rrpart->crop) { /* filters add pixel extra */ offs = (rrpart->crop + rrpart->crop * rrpart->rectx); } else { offs = 0; } /* passes are allocated in sync */ for (rpassp = rlp->passes.first; rpassp; rpassp = rpassp->next) { const int xstride = rpassp->channels; int a; char passname[EXR_PASS_MAXNAME]; for (a = 0; a < xstride; a++) { set_pass_name(passname, rpassp->passtype, a, rpassp->view); IMB_exr_set_channel(rl->exrhandle, rlp->name, passname, xstride, xstride * rrpart->rectx, rpassp->rect + a + xstride * offs); } } } party = rrpart->tilerect.ymin + rrpart->crop; partx = rrpart->tilerect.xmin + rrpart->crop; for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) { rl = RE_GetRenderLayer(rr, rlp->name); /* should never happen but prevents crash if it does */ BLI_assert(rl); if (UNLIKELY(rl == NULL)) { continue; } IMB_exrtile_write_channels(rl->exrhandle, partx, party, 0, viewname); } BLI_unlock_thread(LOCK_IMAGE); }
/* called for reading temp files, and for external engines */ int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, const char *filepath) { RenderLayer *rl; RenderPass *rpass; void *exrhandle = IMB_exr_get_handle(); int rectx, recty; if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty) == 0) { printf("failed being read %s\n", filepath); IMB_exr_close(exrhandle); return 0; } if (rr == NULL || rectx != rr->rectx || recty != rr->recty) { if (rr) printf("error in reading render result: dimensions don't match\n"); else printf("error in reading render result: NULL result pointer\n"); IMB_exr_close(exrhandle); return 0; } for (rl = rr->layers.first; rl; rl = rl->next) { if (rl_single && rl_single != rl) continue; /* passes are allocated in sync */ for (rpass = rl->passes.first; rpass; rpass = rpass->next) { const int xstride = rpass->channels; int a; char passname[EXR_PASS_MAXNAME]; for (a = 0; a < xstride; a++) { set_pass_name(passname, rpass->passtype, a, rpass->view); IMB_exr_set_channel(exrhandle, rl->name, passname, xstride, xstride * rectx, rpass->rect + a); } set_pass_name(rpass->name, rpass->passtype, -1, rpass->view); } } IMB_exr_read_channels(exrhandle); IMB_exr_close(exrhandle); return 1; }