[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46740] trunk/blender/source/blender: rna function Image.scale(w, h), useful for utility functions to open/scale /save images.
Campbell Barton
ideasman42 at gmail.com
Thu May 17 17:26:12 CEST 2012
Revision: 46740
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46740
Author: campbellbarton
Date: 2012-05-17 15:26:11 +0000 (Thu, 17 May 2012)
Log Message:
-----------
rna function Image.scale(w, h), useful for utility functions to open/scale/save images.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_image.h
trunk/blender/source/blender/blenkernel/intern/image.c
trunk/blender/source/blender/makesrna/intern/rna_image_api.c
Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h 2012-05-17 15:24:26 UTC (rev 46739)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h 2012-05-17 15:26:11 UTC (rev 46740)
@@ -183,6 +183,9 @@
/* merge source into dest, and free source */
void BKE_image_merge(struct Image *dest, struct Image *source);
+/* scale the image */
+void BKE_image_scale(struct Image *image, int width, int height);
+
/* check if texture has alpha (depth=32) */
int BKE_image_has_alpha(struct Image *image);
Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c 2012-05-17 15:24:26 UTC (rev 46739)
+++ trunk/blender/source/blender/blenkernel/intern/image.c 2012-05-17 15:26:11 UTC (rev 46740)
@@ -505,6 +505,20 @@
}
}
+/* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */
+void BKE_image_scale(Image *image, int width, int height)
+{
+ ImBuf *ibuf;
+ void *lock;
+
+ ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
+
+ IMB_scaleImBuf(ibuf, width, height);
+ ibuf->userflags |= IB_BITMAPDIRTY;
+
+ BKE_image_release_ibuf(image, lock);
+}
+
Image *BKE_image_load(const char *filepath)
{
Image *ima;
Modified: trunk/blender/source/blender/makesrna/intern/rna_image_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2012-05-17 15:24:26 UTC (rev 46739)
+++ trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2012-05-17 15:26:11 UTC (rev 46740)
@@ -178,6 +178,11 @@
IMB_rect_from_float(ibuf);
}
+static void rna_Image_scale(Image *image, int width, int height)
+{
+ BKE_image_scale(image, width, height);
+}
+
static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int mag)
{
ImBuf *ibuf;
@@ -262,6 +267,13 @@
RNA_def_function_ui_description(func, "Update the display image from the floating point buffer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ func = RNA_def_function(srna, "scale", "rna_Image_scale");
+ RNA_def_function_ui_description(func, "Scale the image in pixels");
+ parm = RNA_def_int(func, "width", 0, 1, 10000, "", "Width", 1, 10000);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
func = RNA_def_function(srna, "gl_load", "rna_Image_gl_load");
RNA_def_function_ui_description(func, "Load the image into OpenGL graphics memory");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
More information about the Bf-blender-cvs
mailing list