[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12367] trunk/blender/source/blender: Patch by GSR #7628, I also added alpha for text background.

Campbell Barton cbarton at metavr.com
Wed Oct 24 00:51:50 CEST 2007


Revision: 12367
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12367
Author:   campbellbarton
Date:     2007-10-24 00:51:50 +0200 (Wed, 24 Oct 2007)

Log Message:
-----------
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.

Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/imbuf/intern/rectop.c
    trunk/blender/source/blender/src/buttons_scene.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2007-10-23 22:38:07 UTC (rev 12366)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2007-10-23 22:51:50 UTC (rev 12367)
@@ -823,17 +823,68 @@
 	
 	IMB_imginfo_change_field (ibuf, "File", G.sce);
 	if (G.scene->r.stamp & R_STAMP_DRAW) {
-		x = 1;
-		y = ibuf->y - font_height;
-		sprintf(text, "File: %s", G.sce);
+		/* Top left corner */
+		x = 1; /* Inits for everyone */
+		y = ibuf->y - font_height; /* Also inits for everyone */
+		sprintf(text, "File %s", G.sce);
 		text_width = BMF_GetStringWidth(font, text);
 		IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-		BMF_DrawStringBuf(font, G.sce, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-		x = 1;
+		BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
 		y -= font_height+1;
 	}
 
+	if (G.scene->r.stamp & R_STAMP_NOTE) {
+		IMB_imginfo_change_field (ibuf, "Note", G.scene->r.stamp_udata);
+ 
+		if (G.scene->r.stamp & R_STAMP_DRAW) {
+			/* Top left corner, below File */
+			text_width = BMF_GetStringWidth(font, G.scene->r.stamp_udata);
+			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+			BMF_DrawStringBuf(font, G.scene->r.stamp_udata, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+			y -= font_height+1;
+		}
+	}
+	
+	if (G.scene->r.stamp & R_STAMP_DATE) {
+#ifdef WIN32
+		_strdate (sdate);
+		sprintf (infotext, "%s", sdate);
+#else
+		t = time (NULL);
+		tl = localtime (&t);
+		sprintf (infotext, "%04d-%02d-%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday);
+#endif /* WIN32 */
+		IMB_imginfo_change_field (ibuf, "Date", infotext);
 
+		if (G.scene->r.stamp & R_STAMP_DRAW) {
+			/* Top left corner, below File (or Note) */
+			sprintf (text, "Date %s", infotext);
+			text_width = BMF_GetStringWidth(font, text);
+			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+		}
+	}
+
+
+	if (G.scene->r.stamp & R_STAMP_MARKER) {
+		TimeMarker *marker = get_frame_marker(CFRA);
+ 		
+		if (marker) strcpy(infotext, marker->name);
+		else 		strcpy(infotext, "<none>");
+ 		
+		IMB_imginfo_change_field (ibuf, "Marker", infotext);
+		
+		if (G.scene->r.stamp & R_STAMP_DRAW) {
+			/* Bottom left corner, leaving space for timing */
+			x = 1;
+			y = font_height+1;
+			sprintf (text, "Marker %s", infotext);
+			text_width = BMF_GetStringWidth(font, text);
+			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ 			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+		}
+	}
+
 	if (G.scene->r.stamp & R_STAMP_TIME) {
 		h= m= s= f= 0;
 		f = (int)(G.scene->r.cfra % G.scene->r.frs_sec);
@@ -857,11 +908,14 @@
 		IMB_imginfo_change_field (ibuf, "Time", infotext);
 		
 		if (G.scene->r.stamp & R_STAMP_DRAW) {
+			/* Left bottom corner */
+			x = 1;
+			y = 1;
 			sprintf (text, "Time %s", infotext);
 			text_width = BMF_GetStringWidth(font, text);
 			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-			x += text_width;
+			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+			x += text_width+text_pad;
 		}
 	}
 
@@ -870,47 +924,35 @@
 		IMB_imginfo_change_field (ibuf, "Frame", infotext);
 
 		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			sprintf (text, "    Frame %s", infotext);
+			char format[32];
+
+			/* First build "Frame %03i" for anims ending in frame 100-999, etc */
+			sprintf(format, "Frame %%0%di\n", 1 + (int) log10(G.scene->r.efra));
+			sprintf (text, format, G.scene->r.cfra);
 			text_width = BMF_GetStringWidth(font, text);
+			/* Left bottom corner (after SMPTE if exists) */
+			if (!(G.scene->r.stamp & R_STAMP_TIME)) {
+				x = 1;
+			}
+			y = 1;
 			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-			x += BMF_GetStringWidth(font, text);
+			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
 		}
 	}
 
-	if (G.scene->r.stamp & R_STAMP_DATE) {
-#ifdef WIN32
-		_strdate (sdate);
-		sprintf (infotext, "%s", sdate);
-#else
-		t = time (NULL);
-		tl = localtime (&t);
-		sprintf (infotext, "%02d-%02d-%02d", tl->tm_mon+1, tl->tm_mday, tl->tm_year-100);
-#endif /* WIN32 */
-		IMB_imginfo_change_field (ibuf, "Date", infotext);
 
-		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			x = 1;
-			y = 1;
-			sprintf (text, "Date %s", infotext);
-			text_width = BMF_GetStringWidth(font, text);
-			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-			x += text_width;
-		}
-	}
-
 	if (G.scene->r.stamp & R_STAMP_CAMERA) {
 		sprintf(infotext, ((Camera *) G.scene->camera)->id.name+2);
 		IMB_imginfo_change_field (ibuf, "Camera", infotext);
 
 		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			sprintf (text, "Camera: %s", infotext);
+			sprintf (text, "Camera %s", infotext);
 			text_width = BMF_GetStringWidth(font, text);
+			/* Center of bottom edge */
 			x = (ibuf->x/2) - (BMF_GetStringWidth(font, text)/2);
 			y = 1;
 			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
 		}
 	}
 
@@ -919,43 +961,15 @@
 		IMB_imginfo_change_field (ibuf, "Scene", infotext);
 
 		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			sprintf (text, "Scene: %s", infotext);
+			sprintf (text, "Scene %s", infotext);
 			text_width = BMF_GetStringWidth(font, text);
+			/* Bottom right corner */
 			x = ibuf->x - (BMF_GetStringWidth(font, text)+1+text_pad);
+			y = 1;
 			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
+			BMF_DrawStringBuf(font, text, x+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
 		}
 	}
-	
-	if (G.scene->r.stamp & R_STAMP_NOTE) {
-		IMB_imginfo_change_field (ibuf, "Note", G.scene->r.stamp_udata);
- 
-		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			x = 1;
-			y = font_height+1;
-			text_width = BMF_GetStringWidth(font, G.scene->r.stamp_udata);
-			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
-			BMF_DrawStringBuf(font, G.scene->r.stamp_udata, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-		}
-	}
-	
-	if (G.scene->r.stamp & R_STAMP_MARKER) {
-		TimeMarker *marker = get_frame_marker(CFRA);
- 		
-		if (marker) strcpy(infotext, marker->name);
-		else 		strcpy(infotext, "None");
- 		
-		IMB_imginfo_change_field (ibuf, "Marker", infotext);
-		
-		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			sprintf (text, "Marker: %s", infotext);
-			x = 1;
-			y = ibuf->y - (font_height+1)*3;
-			text_width = BMF_GetStringWidth(font, text);
-			IMB_rectfill_area(ibuf, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- 			BMF_DrawStringBuf(font, text, x, y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
-		}
-	}
 }
 
 int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quality)

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2007-10-23 22:38:07 UTC (rev 12366)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2007-10-23 22:51:50 UTC (rev 12367)
@@ -6781,6 +6781,8 @@
 		Scene *sce;
 		for(sce= main->scene.first; sce; sce=sce->id.next) {
 			sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8;
+			sce->r.fg_stamp[3] = 1.0; /* dont use text alpha yet */
+			sce->r.bg_stamp[3] = 0.25; /* make sure the background has full alpha */
 		}
 	}
 

Modified: trunk/blender/source/blender/imbuf/intern/rectop.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/rectop.c	2007-10-23 22:38:07 UTC (rev 12366)
+++ trunk/blender/source/blender/imbuf/intern/rectop.c	2007-10-23 22:51:50 UTC (rev 12367)
@@ -524,7 +524,7 @@
 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2)
 {
 	int i, j;
-	
+	float a, ai;
 	if ((!ibuf) || (!col))
 		return;
 	
@@ -538,6 +538,9 @@
 	if (y1>y2) SWAP(int,y1,y2);
 	if (x1==x2 || y1==y2) return;
 	
+	a = col[3];
+	ai = 1-a;
+	
 	if (ibuf->rect) {
 		unsigned char *img, *pixel; 
 		unsigned char chr, chg, chb;
@@ -550,9 +553,16 @@
 		for (j = 0; j < y2-y1; j++) {
 			for (i = 0; i < x2-x1; i++) {
 				pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i));
-				pixel[0] = chr;
-				pixel[1] = chg;
-				pixel[2] = chb;
+				if (a == 1.0) {
+					pixel[0] = chr;
+					pixel[1] = chg;
+					pixel[2] = chb;
+				} else {
+					pixel[0] = (char)((chr*a) + (pixel[0]*ai));
+					pixel[1] = (char)((chg*a) + (pixel[1]*ai));
+					pixel[2] = (char)((chb*a) + (pixel[2]*ai));
+				}
+				
 			}
 		}
 	}
@@ -563,9 +573,15 @@
 		for (j = 0; j < y2-y1; j++) {
 			for (i = 0; i < x2-x1; i++) {
 				pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i));

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list