MultiLayer images: added support for choosing compression type.
authorTon Roosendaal <ton@blender.org>
Thu, 21 Dec 2006 10:41:43 +0000 (10:41 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 21 Dec 2006 10:41:43 +0000 (10:41 +0000)
Without setting anything, it uses ZIP now as default, which gives the best
lossless compression and works nice fast.

source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/imbuf/intern/openexr/openexr_multi.h
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blender/src/buttons_scene.c
source/blender/src/editsima.c
source/blender/src/writeimage.c

index 833008c3d7eb6a6ce64301fa788f6c25086e5771..c035862c23ffc63c74cd98201c8929e04567610b 100644 (file)
@@ -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"));
        
index feceb227e4b2153017b0062753067802b09f21fc..b9aa81e81dac2db39a60f80a4137097d54a223d0 100644 (file)
@@ -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) {}
index 72f266630c4b53bdce5717afb27add4aa4207706..bd210501330acc0ef57fd80ef51f6d27ef6288c7 100644 (file)
@@ -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! */
index e62d66a354dbbc7ab2fdb2b33d2831652d449ee7..0638423e7e7a4d0397c445b1ed0f916ba95788eb 100644 (file)
@@ -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);
                        }
                }
index e96bf44cd94da9e6af4bbdfdae13285abcabff10..9a4d3514e9d32b66e1e5fdd768a2523d9ac2eee6 100644 (file)
@@ -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");
                
index 21a74dc95d399841919f4916141642df1f50caab..cb25f615414b54b34dfa73920a91b6247d1d0f51 100644 (file)
@@ -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));
index 530d0535baa268fc0419776c613863f0ed793588..3ef29169b54a2598508dee32fbed946275e58243 100644 (file)
@@ -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;