Keep image dimension used by space image and some other tools sync
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Jan 2016 11:04:50 +0000 (12:04 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Jan 2016 11:07:21 +0000 (12:07 +0100)
When using an empty render result (after re-opening the file, i.e.)
some tools (like masking) could have used wrong image resolution
because of not being aware of special cases supported by the image
space to display the render result.

This should fix selecting mask points when mask is opened op top
if an empty render result.

source/blender/blenkernel/intern/image.c

index ad1f30555a85968b9bb2d59c742f21cf31ebba7d..7c40674dd6c0ee0f68ef4e7c6ffa69c60d3961e0 100644 (file)
@@ -4410,6 +4410,15 @@ void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
                *width = ibuf->x;
                *height = ibuf->y;
        }
+       else if (image->type == IMA_TYPE_R_RESULT && iuser != NULL && iuser->scene != NULL) {
+               Scene *scene = iuser->scene;
+               *width = (scene->r.xsch * scene->r.size) / 100;
+               *height = (scene->r.ysch * scene->r.size) / 100;
+               if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
+                       *width *= BLI_rctf_size_x(&scene->r.border);
+                       *height *= BLI_rctf_size_y(&scene->r.border);
+               }
+       }
        else {
                *width  = IMG_SIZE_FALLBACK;
                *height = IMG_SIZE_FALLBACK;