rna image.file_format, can be set before saving to choose a file format from a genera...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 7 Mar 2010 20:27:40 +0000 (20:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 7 Mar 2010 20:27:40 +0000 (20:27 +0000)
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_scene.c

index 5e93339dd643cd3fd07c819e8d9403a281ff2b7c..231ab766d6cac260646e976ea8de89629cfd186f 100644 (file)
@@ -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[];
index 8996ac078dd3d4ded2265314c50aa2163a7da67b..1657ad00cdd1bad54e5eb1bc38b7123b7a783823 100644 (file)
@@ -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");
index ca42ff12531a989a8eb2afb03cb6f0f467a4f8db..9872d6e1801d81f518b22d53e19e766e2996a1ce 100644 (file)
@@ -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[] = {