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-09-13 09:29:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-13 09:29:38 +0400
commit05755d307a140934aba98e55e9c7536c0cba0947 (patch)
treeadb0988fa03ea2ae11d785e78a164d4c90e82df2 /source/blender/blenkernel/intern/image.c
parentc5310521f8d9099fc36431bae76dd0a402cc077e (diff)
fix [#31946] Masking doesn't respect pixel ratio
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index ac307e036bf..3f756e74b26 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2931,3 +2931,40 @@ int BKE_image_has_alpha(struct Image *image)
else
return 0;
}
+
+void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
+{
+ ImBuf *ibuf = NULL;
+ void *lock;
+
+ ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
+
+ if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
+ *width = ibuf->x;
+ *height = ibuf->y;
+ }
+ else {
+ *width = IMG_SIZE_FALLBACK;
+ *height = IMG_SIZE_FALLBACK;
+ }
+
+ BKE_image_release_ibuf(image, lock);
+}
+
+void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float size[2])
+{
+ int width, height;
+ BKE_image_get_size(image, iuser, &width, &height);
+
+ size[0] = (float)width;
+ size[1] = (float)height;
+
+}
+
+void BKE_image_get_aspect(Image *image, float *aspx, float *aspy)
+{
+ *aspx = 1.0;
+
+ /* x is always 1 */
+ *aspy = image->aspy / image->aspx;
+}