ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
if(ibuf) {
- short ibuf_free= FALSE;
-
/* color -> greyscale */
/* editing directly would alter the render view */
if(scene->r.planes == 8) {
IMB_color_to_bw(ibuf_bw);
// IMB_freeImBuf(ibuf); /* owned by the image */
ibuf= ibuf_bw;
-
- ibuf_free= TRUE;
+ }
+ else {
+ /* this is lightweight & doesnt re-alloc the buffers, only do this
+ * to save the correct bit depth since the image is always RGBA */
+ ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.planes, 0);
+ ibuf_cpy->rect= ibuf->rect;
+ ibuf_cpy->rect_float= ibuf->rect_float;
+ ibuf_cpy->zbuf_float= ibuf->zbuf_float;
+ ibuf= ibuf_cpy;
}
if(BKE_imtype_is_movie(scene->r.imtype)) {
}
}
- if(ibuf_free) {
- IMB_freeImBuf(ibuf);
- }
+ /* imbuf knows which rects are not part of ibuf */
+ IMB_freeImBuf(ibuf);
}
BKE_image_release_ibuf(oglrender->ima, lock);