diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-22 00:19:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-22 00:19:58 +0400 |
commit | 0e2c8cdcdd13a49560e6f105de530c2ef94ed4e4 (patch) | |
tree | 0f53d799ec422ddc96dd948136061e08233abdf4 /source/blender/editors | |
parent | e0482b2def521df87f09c7aa23e58909f5e19b90 (diff) |
move image settings into their own structure so the interface can be shared where image saving settings are needed.
currently file out node and render output share this struct & UI.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/render/render_internal.c | 4 | ||||
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 24 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 68 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 42 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 22 |
8 files changed, 135 insertions, 44 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index a0b477413e4..4b8817334f0 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -748,6 +748,7 @@ void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char * void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer); void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact); +void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6931b0b86db..dbd1e27024e 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -235,7 +235,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } @@ -516,7 +516,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 188a61181ce..97e93eb2e7f 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -220,12 +220,12 @@ static void screen_opengl_render_apply(OGLRender *oglrender) char name[FILE_MAX]; int ok; - if(scene->r.planes == 8) { + if(scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) { IMB_color_to_bw(ibuf); } - BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); /* no need to stamp here */ + BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); + ok= BKE_write_ibuf(ibuf, name, &scene->r.im_format); /* no need to stamp here */ if(ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -263,7 +263,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) return 0; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return 0; } @@ -332,7 +332,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) Scene *scene= oglrender->scene; if(oglrender->mh) { - if(BKE_imtype_is_movie(scene->r.imtype)) + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) oglrender->mh->end_movie(); } @@ -371,8 +371,8 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) scene= oglrender->scene; oglrender->reports= op->reports; - oglrender->mh= BKE_get_movie_handle(scene->r.imtype); - if(BKE_imtype_is_movie(scene->r.imtype)) { + oglrender->mh= BKE_get_movie_handle(scene->r.im_format.imtype); + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); return 0; @@ -440,7 +440,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(ibuf) { /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.planes == 8) { + if(scene->r.im_format.planes == R_PLANESBW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); // IMB_freeImBuf(ibuf); /* owned by the image */ @@ -449,14 +449,14 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) else { /* this is lightweight & doesnt re-alloc the buffers, only do this * to save the correct bit depth since the image is always RGBA */ - ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.planes, 0); + ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.im_format.planes, 0); ibuf_cpy->rect= ibuf->rect; ibuf_cpy->rect_float= ibuf->rect_float; ibuf_cpy->zbuf_float= ibuf->zbuf_float; ibuf= ibuf_cpy; } - if(BKE_imtype_is_movie(scene->r.imtype)) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { ok= oglrender->mh->append_movie(&scene->r, CFRA, (int*)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports); if(ok) { printf("Append frame %d", scene->r.cfra); @@ -464,8 +464,8 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); + ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index e2e48a489b6..cf14432754f 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -680,7 +680,7 @@ static int envmap_save_exec(bContext *C, wmOperator *op) Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; Scene *scene = CTX_data_scene(C); //int imtype = RNA_enum_get(op->ptr, "file_type"); - int imtype = scene->r.imtype; + int imtype = scene->r.im_format.imtype; char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); @@ -707,7 +707,7 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event if(RNA_property_is_set(op->ptr, "filepath")) return envmap_save_exec(C, op); - //RNA_enum_set(op->ptr, "file_type", scene->r.imtype); + //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype); RNA_string_set(op->ptr, "filepath", G.main->name); WM_event_add_fileselect(C, op); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 8a90aadbee2..48970dffce0 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -161,12 +161,12 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* BKE_add_image_extension() checks for if extension was already set */ if(scene->r.scemode & R_EXTENSION) if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5) - BKE_add_image_extension(path, scene->r.imtype); + BKE_add_image_extension(path, scene->r.im_format.imtype); ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect= scd->dumprect; - BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); + BKE_write_ibuf(ibuf, path, &scene->r.im_format); IMB_freeImBuf(ibuf); } @@ -261,14 +261,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float { ScreenshotJob *sj= sjv; RenderData rd= sj->scene->r; - bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.imtype); + bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype); int cfra= 1; /* we need this as local variables for renderdata */ rd.frs_sec= U.scrcastfps; rd.frs_sec_base= 1.0f; - if(BKE_imtype_is_movie(rd.imtype)) { + if(BKE_imtype_is_movie(rd.im_format.imtype)) { if(!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { printf("screencast job stopped\n"); return; @@ -294,14 +294,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float break; } else { - ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.planes, 0); + ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); char name[FILE_MAXDIR+FILE_MAXFILE]; int ok; - BKE_makepicstring(name, rd.pic, sj->bmain->name, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE); + BKE_makepicstring(name, rd.pic, sj->bmain->name, cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE); ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(ibuf, name, rd.imtype, rd.subimtype, rd.quality); + ok= BKE_write_ibuf(ibuf, name, &rd.im_format); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index df5c8d4c7cd..48627e9d1ed 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -817,6 +817,74 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char MEM_freeN(cb); } +void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) +{ + ImageFormatData *imf= imfptr->data; + ID *id= imfptr->id.data; + const int depth_ok= BKE_imtype_is_depth_ok(imf->imtype); + /* some settings depend on this being a scene thats rendered */ + const short is_render_out= (id && GS(id->name) == ID_SCE); + + uiLayout *col, *row; + + col= uiLayoutColumn(layout, 0); + + uiItemR(col, imfptr, "file_format", 0, "", ICON_NONE); + + row= uiLayoutRow(col, 0); + uiItemR(row, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE); + + /* only display depth setting if multiple depths can be used */ + if((ELEM6(depth_ok, + R_IMF_CHAN_DEPTH_1, + R_IMF_CHAN_DEPTH_8, + R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_16, + R_IMF_CHAN_DEPTH_24, + R_IMF_CHAN_DEPTH_32)) == 0) + { + row= uiLayoutRow(col, 0); + uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + } + + if (BKE_imtype_is_quality_ok(imf->imtype)) { + uiItemR(col, imfptr, "quality", 0, NULL, ICON_NONE); + } + + if (BKE_imtype_is_compression_ok(imf->imtype)) { + uiItemR(col, imfptr, "compression", 0, NULL, ICON_NONE); + } + + if (BKE_imtype_is_zbuf_ok(imf->imtype)) { + uiItemR(col, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); + } + + if (ELEM(imf->imtype, R_OPENEXR, R_MULTILAYER)) { + uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); + + if (is_render_out && (imf->imtype == R_OPENEXR)) { + uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE); + } + } + + if (imf->imtype == R_JP2) { + uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); + } + + if (imf->imtype == R_CINEON) { +#if 1 + uiItemL(col, "FIXME: hard coded Non-Linear, Gamma:1.0", ICON_NONE); +#else + uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_white", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE); +#endif + } +} + void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) { Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 77c92b2d9c3..448e109e98a 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -967,8 +967,8 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, simopts->planes= ibuf->depth; if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { - simopts->imtype= scene->r.imtype; - simopts->planes= scene->r.planes; + simopts->imtype= scene->r.im_format.imtype; + simopts->planes= scene->r.im_format.planes; } else if (ima->source == IMA_SRC_GENERATED) { simopts->imtype= R_PNG; @@ -976,7 +976,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, else { simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype); } - simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ + //simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ simopts->quality= ibuf->ftype & 0xff; BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath)); @@ -990,7 +990,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, /* some formats dont use quality so fallback to scenes quality */ if (simopts->quality == 0) { - simopts->quality= scene->r.quality; + simopts->quality= scene->r.im_format.quality; } /* check for empty path */ @@ -1017,7 +1017,8 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op #if 0 if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX #else - simopts->subimtype= evil_scene->r.subimtype; +// simopts->subimtype= evil_scene->r.subimtype; + (void)evil_scene; #endif if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality"); @@ -1086,8 +1087,18 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } BKE_image_release_renderresult(scene, ima); } - else if (BKE_write_ibuf(ibuf, simopts->filepath, simopts->imtype, simopts->subimtype, simopts->quality)) { - ok= TRUE; + else { + ImageFormatData imf= {0}; + + /* todo, make operator use template, this works for now */ + imf.imtype= simopts->imtype; + imf.quality= simopts->quality; + imf.compress= simopts->quality; + imf.depth= R_IMF_CHAN_DEPTH_8; + + if (BKE_write_ibuf(ibuf, simopts->filepath, &imf)) { + ok= TRUE; + } } if (ok) { @@ -1191,6 +1202,22 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve return OPERATOR_RUNNING_MODAL; } +#if 0 +static void image_save_as_draw(bContext *C, wmOperator *op) +{ + ImageFormatData *imf= op->customdata; + PointerRNA ptr; + + /* image template */ + RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &ptr); + uiTemplateImageSettings(layout, &ptr); + + /* main draw call */ + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + uiDefAutoButsRNA(layout, &ptr, NULL, '\0'); +} +#endif + void IMAGE_OT_save_as(wmOperatorType *ot) { PropertyRNA *prop; @@ -1203,6 +1230,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->exec= image_save_as_exec; ot->check= image_save_as_check; ot->invoke= image_save_as_invoke; + // ot->ui= image_save_as_draw; ot->poll= space_image_buffer_exists_poll; /* flags */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 92592a7c071..47cfa5c763d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1633,24 +1633,18 @@ static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), Po static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + bNode *node= ptr->data; + NodeImageFile *nif= node->storage; + PointerRNA imfptr; + uiLayout *col, *row; col= uiLayoutColumn(layout, 0); uiItemR(col, ptr, "filepath", 0, "", ICON_NONE); - uiItemR(col, ptr, "image_type", 0, "", ICON_NONE); - - row= uiLayoutRow(layout, 0); - if (RNA_enum_get(ptr, "image_type")== R_OPENEXR) { - uiItemR(row, ptr, "use_exr_half", 0, NULL, ICON_NONE); - uiItemR(row, ptr, "exr_codec", 0, "", ICON_NONE); - } - else if (RNA_enum_get(ptr, "image_type")== R_JPEG90) { - uiItemR(row, ptr, "quality", UI_ITEM_R_SLIDER, "Quality", ICON_NONE); - } - else if (RNA_enum_get(ptr, "image_type")== R_PNG) { - uiItemR(row, ptr, "quality", UI_ITEM_R_SLIDER, "Compression", ICON_NONE); - } - + + RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &nif->im_format, &imfptr); + uiTemplateImageSettings(layout, &imfptr); + row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "frame_start", 0, "Start", ICON_NONE); uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE); |