Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-17 19:26:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-17 19:26:11 +0400
commit2c23bb838979131667c922df1f01738e02e6ca16 (patch)
tree882ca4da661caacbc40d6aecbd65c873c49d22d3
parentbb2b1694abca9e1a2a130647aca642020ccd502f (diff)
rna function Image.scale(w, h), useful for utility functions to open/scale/save images.
-rw-r--r--source/blender/blenkernel/BKE_image.h3
-rw-r--r--source/blender/blenkernel/intern/image.c14
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c12
3 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 97b724c09e4..91e3e9edbf0 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -183,6 +183,9 @@ struct Image *BKE_image_copy(struct Image *ima);
/* 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);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 6ee15409857..91eed8b0b60 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -505,6 +505,20 @@ void BKE_image_merge(Image *dest, Image *source)
}
}
+/* 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;
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index f191303a92c..3d937fc561d 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -178,6 +178,11 @@ static void rna_Image_update(Image *image, ReportList *reports)
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 @@ void RNA_api_image(StructRNA *srna)
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);