fix [#27862] OpenGL render animation don't respect .png RGB option.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 5 Jul 2011 07:46:25 +0000 (07:46 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 5 Jul 2011 07:46:25 +0000 (07:46 +0000)
source/blender/editors/render/render_opengl.c

index a55f9101a0f662a6614dbd0490f23c5fb02c2175..3256112426bb4497a5fec16ad2aeecf27498f536 100644 (file)
@@ -438,8 +438,6 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
        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) {
@@ -447,8 +445,15 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                        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)) {
@@ -472,9 +477,8 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                        }
                }
 
-               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);