opengl stamp wasnt working right, stamp assumed an alpha channel existed.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 20 Jan 2008 23:52:48 +0000 (23:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 20 Jan 2008 23:52:48 +0000 (23:52 +0000)
intern/bmfont/BMF_Api.h
intern/bmfont/intern/BMF_Api.cpp
intern/bmfont/intern/BMF_BitmapFont.cpp
intern/bmfont/intern/BMF_BitmapFont.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/render/intern/source/pipeline.c
source/blender/src/renderwin.c

index 1b4a4ee3129ff0aa7596865b56ac97bc9b75fca6..4465242e9fa2d8826e47efbec095d17d1dc8a565 100644 (file)
@@ -152,8 +152,9 @@ void BMF_DrawStringTexture(BMF_Font* font, char* string, float x, float y, float
  * @param fbuf float image buffer, when NULL to not operate on it.
  * @param w image buffer width.
  * @param h image buffer height.
+ * @param channels number of channels in the image (3 or 4 - currently)
         */
-void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h);
+void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels);
 
 
 #ifdef __cplusplus
index eaa8ffb939d624cca906263556f6dba9cba3fc9b..24e053515fba32b5b85c93b8f1647cc145ea003a 100644 (file)
@@ -180,7 +180,7 @@ void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float
        ((BMF_BitmapFont*)font)->DrawStringTexture(string, x, y, z);
 }
 
-void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h) {
+void BMF_DrawStringBuf(BMF_Font* font, char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels) {
        if (!font) return;
-       ((BMF_BitmapFont*)font)->DrawStringBuf(str, posx, posy, col, buf, fbuf, w, h);
+       ((BMF_BitmapFont*)font)->DrawStringBuf(str, posx, posy, col, buf, fbuf, w, h, channels);
 }
index 8e670c099a33ce0624db3d47cfd69dbab90bec35..afdcf7fbfbb8136b338dd63d1e0e6ea9fc42970c 100644 (file)
@@ -241,7 +241,7 @@ void BMF_BitmapFont::DrawStringTexture(char *str, float x, float y, float z)
 }
 
 #define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val))
-void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h)
+void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels)
 {
        int x, y;
        
@@ -277,7 +277,9 @@ void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, un
                                                                pixel[0] = colch[0];
                                                                pixel[1] = colch[1];
                                                                pixel[2] = colch[2];
-                                                               pixel[4] = 1; /*colch[3];*/
+                                                               if (channels==4) {
+                                                                       pixel[4] = 1; /*colch[3];*/
+                                                               }
                                                                
                                                        }
                                                }
@@ -310,7 +312,9 @@ void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, un
                                                                pixel[0] = col[0];
                                                                pixel[1] = col[1];
                                                                pixel[2] = col[2];
-                                                               pixel[3] = 1; /*col[3];*/
+                                                               if (channels==4) {
+                                                                       pixel[3] = 1; /*col[3];*/
+                                                               }
                                                        }
                                                }
                                        }
index 986de2bb399debfc38e830bb2ac871881d2cf286..f8d3d5370dde86feaa0f02a569b4ca659aca25f8 100644 (file)
@@ -130,8 +130,9 @@ public:
         * @param fbuf float image buffer, when NULL to not operate on it.
         * @param w image buffer width.
         * @param h image buffer height.
+        * @param channels number of channels in the image (3 or 4 - currently)
         */
-       void DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h);
+       void DrawStringBuf(char *str, int posx, int posy, float *col, unsigned char *buf, float *fbuf, int w, int h, int channels);
        
 protected:
        /** Pointer to the font data. */
index 47716e660779cfc3f694e72a3acda1acc7517cd2..ca34240cf2711d8bfc588cd2627d22a82c2ffd38 100644 (file)
@@ -47,7 +47,7 @@ struct anim;
 void   free_image(struct Image *me);
 
 void   BKE_stamp_info(struct ImBuf *ibuf);
-void   BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height);
+void   BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels);
 int            BKE_write_ibuf(struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
 void   BKE_makepicstring(char *string, char *base, int frame, int imtype);
 void   BKE_add_image_extension(char *string, int imtype);
index 57370688e15ea83876c259ff96175461db8f4385..0c45356eb0b17f1e07a91935876e57d4130ad711 100644 (file)
@@ -969,7 +969,7 @@ static void stampdata(StampData *stamp_data, int do_prefix)
        }
 }
 
-void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
+void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels)
 {
        struct StampData stamp_data;
        
@@ -1017,7 +1017,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                /* Top left corner */
                text_width = BMF_GetStringWidth(font, stamp_data.file);
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
                y -= font_height+2; /* Top and bottom 1 pix padding each */
        }
 
@@ -1025,7 +1025,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
        if (stamp_data.note[0]) {
                text_width = BMF_GetStringWidth(font, stamp_data.note);
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
                y -= font_height+2; /* Top and bottom 1 pix padding each */
        }
        
@@ -1033,7 +1033,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
        if (stamp_data.date[0]) {
                text_width = BMF_GetStringWidth(font, stamp_data.date);
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
 
        /* Bottom left corner, leaving space for timing */
@@ -1042,7 +1042,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */
                text_width = BMF_GetStringWidth(font, stamp_data.marker);
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
        
        /* Left bottom corner */
@@ -1051,7 +1051,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                y = 1;
                text_width = BMF_GetStringWidth(font, stamp_data.time);
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
                x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
        }
        
@@ -1061,7 +1061,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                if (!stamp_data.time[0])        x = 1;
                y = 1;
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
 
        if (stamp_data.camera[0]) {
@@ -1070,7 +1070,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2);
                y = 1;
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
        
        if (stamp_data.scene[0]) {
@@ -1079,7 +1079,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                x = width - (text_width+1+text_pad);
                y = 1;
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
        
        if (stamp_data.strip[0]) {
@@ -1088,7 +1088,7 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
                x = width - (text_width+1+text_pad);
                y = height - font_height - 1;
                buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-               BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height);
+               BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
        }
        
 }
index ab66be1b6928d319283350fb31040536b46f347f..b8e3091ae4a55bde4c60a82fee689bf253f0c032 100644 (file)
@@ -2022,7 +2022,7 @@ static void renderresult_stampinfo()
        RenderResult rres;
        /* this is the basic trick to get the displayed float or char rect from render result */
        RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
-       BKE_stamp_buf((unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty);
+       BKE_stamp_buf((unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4);
 }
 
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
index e97fdef27ff754f95dd9dd64fbd4dcc65ccb5db8..46af717f2e3a6ee90a39af7a4ec6c3f118ca3b11 100644 (file)
@@ -1301,7 +1301,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
                        do_ogl_view3d_render(re, v3d, winx, winy);
                        glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
                        if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
-                               BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+                               BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty, 3);
                        }
                        window_swap_buffers(render_win->win);
                        
@@ -1343,7 +1343,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
                do_ogl_view3d_render(re, v3d, winx, winy);
                glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
                if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
-                       BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+                       BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty, 3);
                }
                window_swap_buffers(render_win->win);
        }