MultiLayer images: added support for choosing compression type.
Without setting anything, it uses ZIP now as default, which gives the best lossless compression and works nice fast.
This commit is contained in:
@@ -173,7 +173,7 @@ static void openexr_header_compression(Header *header, int compression)
|
||||
header->compression() = RLE_COMPRESSION;
|
||||
break;
|
||||
default:
|
||||
header->compression() = NO_COMPRESSION;
|
||||
header->compression() = ZIP_COMPRESSION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -430,7 +430,7 @@ void IMB_exr_add_channel(void *handle, const char *layname, const char *passname
|
||||
BLI_addtail(&data->channels, echan);
|
||||
}
|
||||
|
||||
void IMB_exr_begin_write(void *handle, char *filename, int width, int height)
|
||||
void IMB_exr_begin_write(void *handle, char *filename, int width, int height, int compress)
|
||||
{
|
||||
ExrHandle *data= (ExrHandle *)handle;
|
||||
Header header (width, height);
|
||||
@@ -442,7 +442,7 @@ void IMB_exr_begin_write(void *handle, char *filename, int width, int height)
|
||||
for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
|
||||
header.channels().insert (echan->name, Channel (FLOAT));
|
||||
|
||||
header.compression() = RLE_COMPRESSION;
|
||||
openexr_header_compression(&header, compress);
|
||||
|
||||
header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43"));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void * IMB_exr_get_handle (void);
|
||||
void IMB_exr_add_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect);
|
||||
|
||||
int IMB_exr_begin_read (void *handle, char *filename, int *width, int *height);
|
||||
void IMB_exr_begin_write (void *handle, char *filename, int width, int height);
|
||||
void IMB_exr_begin_write (void *handle, char *filename, int width, int height, int compress);
|
||||
void IMB_exrtile_begin_write (void *handle, char *filename, int width, int height, int tilex, int tiley);
|
||||
|
||||
void IMB_exr_set_channel (void *handle, char *layname, char *passname, int xstride, int ystride, float *rect);
|
||||
@@ -69,7 +69,7 @@ void * IMB_exr_get_handle (void) {return NULL;}
|
||||
void IMB_exr_add_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) {}
|
||||
|
||||
int IMB_exr_begin_read (void *handle, char *filename, int *width, int *height) {return 0;}
|
||||
void IMB_exr_begin_write (void *handle, char *filename, int width, int height) {}
|
||||
void IMB_exr_begin_write (void *handle, char *filename, int width, int height, int compress) {}
|
||||
void IMB_exrtile_begin_write (void *handle, char *filename, int width, int height, int tilex, int tiley) {}
|
||||
|
||||
void IMB_exr_set_channel (void *handle, char *layname, char *channame, int xstride, int ystride, float *rect) {}
|
||||
|
||||
@@ -180,7 +180,7 @@ void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame);
|
||||
void RE_BlenderAnim(struct Render *re, struct Scene *scene, int sfra, int efra);
|
||||
|
||||
void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode);
|
||||
void RE_WriteRenderResult(RenderResult *rr, char *filename);
|
||||
void RE_WriteRenderResult(RenderResult *rr, char *filename, int compress);
|
||||
struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty);
|
||||
|
||||
/* ancient stars function... go away! */
|
||||
|
||||
@@ -694,7 +694,7 @@ static char *make_pass_name(RenderPass *rpass, int chan)
|
||||
|
||||
/* filename already made absolute */
|
||||
/* called from within UI, saves both rendered result as a file-read result */
|
||||
void RE_WriteRenderResult(RenderResult *rr, char *filename)
|
||||
void RE_WriteRenderResult(RenderResult *rr, char *filename, int compress)
|
||||
{
|
||||
RenderLayer *rl;
|
||||
RenderPass *rpass;
|
||||
@@ -733,7 +733,7 @@ void RE_WriteRenderResult(RenderResult *rr, char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty);
|
||||
IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress);
|
||||
|
||||
IMB_exr_write_channels(exrhandle);
|
||||
IMB_exr_close(exrhandle);
|
||||
@@ -2175,7 +2175,7 @@ static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh)
|
||||
|
||||
if(re->r.imtype==R_MULTILAYER) {
|
||||
if(re->result) {
|
||||
RE_WriteRenderResult(re->result, name);
|
||||
RE_WriteRenderResult(re->result, name, scene->r.quality);
|
||||
printf("Saved: %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1540,15 +1540,16 @@ static void render_panel_format(void)
|
||||
}
|
||||
#ifdef WITH_OPENEXR
|
||||
}
|
||||
else if (G.scene->r.imtype == R_OPENEXR ) {
|
||||
if (G.scene->r.quality > 5) G.scene->r.quality = 0;
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half", 892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bits float 'Half' type");
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf", 952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the zbuffer as 32 bits unsigned int");
|
||||
uiBlockEndAlign(block);
|
||||
uiDefButBitS(block, TOG, R_PREVIEW_JPG, B_NOP,"Preview",1027,yofs+44,90,20, &G.scene->r.subimtype, 0, 0, 0, 0, "When animation render, save JPG preview images in same directory");
|
||||
else if (ELEM(G.scene->r.imtype, R_OPENEXR, R_MULTILAYER)) {
|
||||
if (G.scene->r.quality > 5) G.scene->r.quality = 2;
|
||||
|
||||
if(G.scene->r.imtype==R_OPENEXR) {
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half", 892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bits float 'Half' type");
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf", 952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the zbuffer as 32 bits unsigned int");
|
||||
uiBlockEndAlign(block);
|
||||
uiDefButBitS(block, TOG, R_PREVIEW_JPG, B_NOP,"Preview",1027,yofs+44,90,20, &G.scene->r.subimtype, 0, 0, 0, 0, "When animation render, save JPG preview images in same directory");
|
||||
}
|
||||
uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",
|
||||
892,yofs,112,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
|
||||
|
||||
|
||||
@@ -1656,7 +1656,7 @@ static void save_image_doit(char *name)
|
||||
if(G.sima->imtypenr==R_MULTILAYER) {
|
||||
RenderResult *rr= BKE_image_get_renderresult(ima);
|
||||
if(rr) {
|
||||
RE_WriteRenderResult(rr, str);
|
||||
RE_WriteRenderResult(rr, str, G.scene->r.quality);
|
||||
|
||||
BLI_strncpy(ima->name, name, sizeof(ima->name));
|
||||
BLI_strncpy(ibuf->name, str, sizeof(ibuf->name));
|
||||
|
||||
@@ -113,7 +113,7 @@ static void save_rendered_image_cb_real(char *name, int confirm)
|
||||
if(G.scene->r.imtype==R_MULTILAYER) {
|
||||
RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name));
|
||||
if(rr)
|
||||
RE_WriteRenderResult(rr, str);
|
||||
RE_WriteRenderResult(rr, str, G.scene->r.quality);
|
||||
}
|
||||
else {
|
||||
RenderResult rres;
|
||||
|
||||
Reference in New Issue
Block a user