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:
authorAndrea Weikert <elubie@gmx.net>2006-01-17 20:23:44 +0300
committerAndrea Weikert <elubie@gmx.net>2006-01-17 20:23:44 +0300
commitd40162bc1a4a9cff9410217cb5359adddf634557 (patch)
tree76468b21dbcef47a2159dbceae3065e150f7f4ec /source/blender/src/interface_icons.c
parenteb839608be902c668256d7a91ff5a5e9c3a6acd9 (diff)
Fixed crash in pupmenu for image icons
* Scaled down image can be smaller than icon - bad memory access * Also needed to copy float buffer for exr images * rectcpy only copied first row There probably is some unnessary copying, will check with a little more time. For now better be safe since it's no huge amount of mem that is copied.
Diffstat (limited to 'source/blender/src/interface_icons.c')
-rw-r--r--source/blender/src/interface_icons.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/src/interface_icons.c b/source/blender/src/interface_icons.c
index dc487ae72fe..a5d5f410eee 100644
--- a/source/blender/src/interface_icons.c
+++ b/source/blender/src/interface_icons.c
@@ -620,6 +620,7 @@ void BIF_icons_init(int first_dyn_id)
static void icon_from_image(Image* img, RenderInfo* ri, unsigned int w, unsigned int h)
{
struct ImBuf *ima;
+ struct ImBuf *imb;
float scaledx, scaledy;
int pr_size = w*h*sizeof(unsigned int);
short ex, ey, dx, dy;
@@ -655,9 +656,18 @@ static void icon_from_image(Image* img, RenderInfo* ri, unsigned int w, unsigned
dx = (w - ex) / 2;
dy = (h - ey) / 2;
- IMB_scaleImBuf(ima, ex, ey);
- memcpy(ri->rect, ima->rect, pr_size);
+ IMB_scalefastImBuf(ima, ex, ey);
+
+ /* sigh, need to copy the float buffer too */
+ imb = IMB_allocImBuf(w, h, 32, IB_rect | IB_rectfloat, 0);
+
+ IMB_rectcpy(imb, ima, dx, dy, 0, 0, ex, ey);
+
IMB_freeImBuf(ima);
+
+ memcpy(ri->rect, imb->rect,pr_size);
+
+ IMB_freeImBuf(imb);
}