support for reading/writing image resolution (dpi), for PNG and TIFF,
[blender-staging.git] / source / blender / makesrna / intern / rna_image.c
index 5872542d10a659640c3825afb18687dca364a70d..3db90c2de0e80aee87ff8d139715d4f2ecb41ef3 100644 (file)
@@ -221,6 +221,39 @@ static void rna_Image_size_get(PointerRNA *ptr,int *values)
        BKE_image_release_ibuf(im, lock);
 }
 
+static void rna_Image_resolution_get(PointerRNA *ptr, float *values)
+{
+       Image *im= (Image*)ptr->data;
+       ImBuf *ibuf;
+       void *lock;
+
+       ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
+       if (ibuf) {
+               values[0]= ibuf->ppm[0];
+               values[1]= ibuf->ppm[1];
+       }
+       else {
+               values[0]= 0;
+               values[1]= 0;
+       }
+
+       BKE_image_release_ibuf(im, lock);
+}
+
+static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
+{
+       Image *im= (Image*)ptr->data;
+       ImBuf *ibuf;
+       void *lock;
+
+       ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
+       if (ibuf) {
+               ibuf->ppm[0]= values[0];
+               ibuf->ppm[1]= values[1];
+       }
+
+       BKE_image_release_ibuf(im, lock);
+}
 
 static int rna_Image_depth_get(PointerRNA *ptr)
 {
@@ -557,6 +590,9 @@ static void rna_def_image(BlenderRNA *brna)
        RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+       prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0);
+       RNA_def_property_float_funcs(prop, "rna_Image_resolution_get" , "rna_Image_resolution_set", NULL);
+
        prop= RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
        RNA_def_property_flag(prop, PROP_DYNAMIC);
        RNA_def_property_multi_array(prop, 1, NULL);