[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13319] trunk/blender: opengl stamp wasnt working right, stamp assumed an alpha channel existed.
Campbell Barton
ideasman42 at gmail.com
Mon Jan 21 00:52:49 CET 2008
Revision: 13319
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13319
Author: campbellbarton
Date: 2008-01-21 00:52:48 +0100 (Mon, 21 Jan 2008)
Log Message:
-----------
opengl stamp wasnt working right, stamp assumed an alpha channel existed.
Modified Paths:
--------------
trunk/blender/intern/bmfont/BMF_Api.h
trunk/blender/intern/bmfont/intern/BMF_Api.cpp
trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp
trunk/blender/intern/bmfont/intern/BMF_BitmapFont.h
trunk/blender/source/blender/blenkernel/BKE_image.h
trunk/blender/source/blender/blenkernel/intern/image.c
trunk/blender/source/blender/render/intern/source/pipeline.c
trunk/blender/source/blender/src/renderwin.c
Modified: trunk/blender/intern/bmfont/BMF_Api.h
===================================================================
--- trunk/blender/intern/bmfont/BMF_Api.h 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/intern/bmfont/BMF_Api.h 2008-01-20 23:52:48 UTC (rev 13319)
@@ -152,8 +152,9 @@
* @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
Modified: trunk/blender/intern/bmfont/intern/BMF_Api.cpp
===================================================================
--- trunk/blender/intern/bmfont/intern/BMF_Api.cpp 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/intern/bmfont/intern/BMF_Api.cpp 2008-01-20 23:52:48 UTC (rev 13319)
@@ -180,7 +180,7 @@
((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);
}
Modified: trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp
===================================================================
--- trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp 2008-01-20 23:52:48 UTC (rev 13319)
@@ -241,7 +241,7 @@
}
#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 @@
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 @@
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];*/
+ }
}
}
}
Modified: trunk/blender/intern/bmfont/intern/BMF_BitmapFont.h
===================================================================
--- trunk/blender/intern/bmfont/intern/BMF_BitmapFont.h 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/intern/bmfont/intern/BMF_BitmapFont.h 2008-01-20 23:52:48 UTC (rev 13319)
@@ -130,8 +130,9 @@
* @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. */
Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h 2008-01-20 23:52:48 UTC (rev 13319)
@@ -47,7 +47,7 @@
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);
Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/source/blender/blenkernel/intern/image.c 2008-01-20 23:52:48 UTC (rev 13319)
@@ -969,7 +969,7 @@
}
}
-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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
}
}
Modified: trunk/blender/source/blender/render/intern/source/pipeline.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pipeline.c 2008-01-20 22:43:48 UTC (rev 13318)
+++ trunk/blender/source/blender/render/intern/source/pipeline.c 2008-01-20 23:52:48 UTC (rev 13319)
@@ -2022,7 +2022,7 @@
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);
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list