diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-07 23:27:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-07 23:27:40 +0300 |
commit | 7f2817f65b3a416de2c514cc8279199e62e3fecd (patch) | |
tree | e29b2a2e6e59e47cfc6a6afc93b8382e6837f15e /source | |
parent | 8a4f9ef831f6a938e694442d197a3d5a21b8ba7a (diff) |
rna image.file_format, can be set before saving to choose a file format from a generated image.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 94 |
3 files changed, 72 insertions, 47 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 5e93339dd64..231ab766d6c 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -48,6 +48,8 @@ extern EnumPropertyItem modifier_type_items[]; extern EnumPropertyItem constraint_type_items[]; extern EnumPropertyItem boidrule_type_items[]; +extern EnumPropertyItem image_type_items[]; + extern EnumPropertyItem beztriple_keyframe_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 8996ac078dd..1657ad00cdd 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -26,6 +26,7 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -142,6 +143,23 @@ static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, in return item; } +static int rna_Image_file_format_get(PointerRNA *ptr) +{ + Image *image= (Image*)ptr->data; + ImBuf *ibuf= BKE_image_get_ibuf(image, NULL); + return BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0); +} + +static void rna_Image_file_format_set(PointerRNA *ptr, int value) +{ + Image *image= (Image*)ptr->data; + if(BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */ + ImBuf *ibuf= BKE_image_get_ibuf(image, NULL); + if(ibuf) + ibuf->ftype= BKE_imtype_to_ftype(value); + } +} + static int rna_Image_has_data_get(PointerRNA *ptr) { Image *im= (Image*)ptr->data; @@ -285,6 +303,11 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Filename", "Image/Movie file name (without data refreshing)"); + prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, image_type_items); + RNA_def_property_enum_funcs(prop, "rna_Image_file_format_get", "rna_Image_file_format_set", NULL); + RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file"); + prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, image_source_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Image_source_itemf"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ca42ff12531..9872d6e1801 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -90,6 +90,53 @@ EnumPropertyItem snap_element_items[] = { {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem image_type_items[] = { + {0, "", 0, "Image", NULL}, + {R_PNG, "PNG", ICON_FILE_IMAGE, "PNG", ""}, + {R_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", ""}, +#ifdef WITH_OPENJPEG + {R_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", ""}, +#endif + {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", ""}, + {R_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", ""}, + {R_RAWTGA, "RAWTARGA", ICON_FILE_IMAGE, "Targa Raw", ""}, + //{R_DDS, "DDS", ICON_FILE_IMAGE, "DDS", ""}, // XXX not yet implemented + {R_HAMX, "HAMX", ICON_FILE_IMAGE, "HamX", ""}, + {R_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", ""}, + {0, "", 0, " ", NULL}, +#ifdef WITH_OPENEXR + {R_OPENEXR, "OPENEXR", ICON_FILE_IMAGE, "OpenEXR", ""}, + {R_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", ""}, +#endif + {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", ""}, // XXX only with G.have_libtiff + {R_RADHDR, "RADHDR", ICON_FILE_IMAGE, "Radiance HDR", ""}, + {R_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", ""}, + {R_DPX, "DPX", ICON_FILE_IMAGE, "DPX", ""}, + {0, "", 0, "Movie", NULL}, + {R_AVIRAW, "AVIRAW", ICON_FILE_MOVIE, "AVI Raw", ""}, + {R_AVIJPEG, "AVIJPEG", ICON_FILE_MOVIE, "AVI JPEG", ""}, +#ifdef _WIN32 + {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", ""}, +#endif +#ifdef WITH_QUICKTIME +# ifdef USE_QTKIT + {R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", ""}, +# else + {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", ""}, +# endif +#endif +#ifdef __sgi + {R_MOVIE, "MOVIE", ICON_FILE_MOVIE, "Movie", ""}, +#endif +#ifdef WITH_FFMPEG + {R_H264, "H264", ICON_FILE_MOVIE, "H.264", ""}, + {R_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", ""}, + {R_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", ""}, + {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "FFMpeg", ""}, +#endif + {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -1712,53 +1759,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, "THREADS_AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"}, {R_FIXED_THREADS, "THREADS_FIXED", 0, "Fixed", "Manually determine the number of threads"}, {0, NULL, 0, NULL, NULL}}; - - static EnumPropertyItem image_type_items[] = { - {0, "", 0, "Image", NULL}, - {R_PNG, "PNG", ICON_FILE_IMAGE, "PNG", ""}, - {R_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", ""}, -#ifdef WITH_OPENJPEG - {R_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", ""}, -#endif - {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", ""}, - {R_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", ""}, - {R_RAWTGA, "RAWTARGA", ICON_FILE_IMAGE, "Targa Raw", ""}, - //{R_DDS, "DDS", ICON_FILE_IMAGE, "DDS", ""}, // XXX not yet implemented - {R_HAMX, "HAMX", ICON_FILE_IMAGE, "HamX", ""}, - {R_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", ""}, - {0, "", 0, " ", NULL}, -#ifdef WITH_OPENEXR - {R_OPENEXR, "OPENEXR", ICON_FILE_IMAGE, "OpenEXR", ""}, - {R_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", ""}, -#endif - {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", ""}, // XXX only with G.have_libtiff - {R_RADHDR, "RADHDR", ICON_FILE_IMAGE, "Radiance HDR", ""}, - {R_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", ""}, - {R_DPX, "DPX", ICON_FILE_IMAGE, "DPX", ""}, - {0, "", 0, "Movie", NULL}, - {R_AVIRAW, "AVIRAW", ICON_FILE_MOVIE, "AVI Raw", ""}, - {R_AVIJPEG, "AVIJPEG", ICON_FILE_MOVIE, "AVI JPEG", ""}, -#ifdef _WIN32 - {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", ""}, -#endif -#ifdef WITH_QUICKTIME -# ifdef USE_QTKIT - {R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", ""}, -# else - {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", ""}, -# endif -#endif -#ifdef __sgi - {R_MOVIE, "MOVIE", ICON_FILE_MOVIE, "Movie", ""}, -#endif -#ifdef WITH_FFMPEG - {R_H264, "H264", ICON_FILE_MOVIE, "H.264", ""}, - {R_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", ""}, - {R_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", ""}, - {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "FFMpeg", ""}, -#endif - {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", ""}, - {0, NULL, 0, NULL, NULL}}; #ifdef WITH_OPENEXR static EnumPropertyItem exr_codec_items[] = { |