[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12371] trunk/blender/source/blender/ blenkernel/intern/image.c: ==Image Stamp - Patch by GSR==

Campbell Barton cbarton at metavr.com
Wed Oct 24 10:45:23 CEST 2007


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

Log Message:
-----------
==Image Stamp - Patch by GSR==

When using non opaque background, some overlap lines appear
due to filling some pixel lines twice. Before it did not matter
as only opaque bg was allowed, and it even compacted the text
a bit. The fix spreads a bit the lines to overcome the issue.
As a plus no text should touch the top edge ever (slashes did,
for example).

Compare:
http://www.infernal-iceberg.com/blender/stamp-alpha-overlap.png
http://www.infernal-iceberg.com/blender/stamp-alpha-cleanup.png

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2007-10-24 07:27:06 UTC (rev 12370)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2007-10-24 08:45:23 UTC (rev 12371)
@@ -819,18 +819,20 @@
 	}
 	
 	font_height = BMF_GetFontHeight(font);
+	/* All texts get halfspace+1 pixel on each side and 1 pix
+	   above and below as padding against their backing rectangles */
 	text_pad = BMF_GetStringWidth(font, " ");
 	
 	IMB_imginfo_change_field (ibuf, "File", G.sce);
 	if (G.scene->r.stamp & R_STAMP_DRAW) {
 		/* Top left corner */
-		x = 1; /* Inits for everyone */
-		y = ibuf->y - font_height; /* Also inits for everyone */
+		x = 1; /* Inits for everyone, text position, so 1 for padding, not 0 */
+		y = ibuf->y - font_height - 1; /* Also inits for everyone, notice padding pixel */
 		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, 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;
+		y -= font_height+2; /* Top and bottom 1 pix padding each */
 	}
 
 	if (G.scene->r.stamp & R_STAMP_NOTE) {
@@ -841,7 +843,7 @@
 			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;
+			y -= font_height+2; /* Top and bottom 1 pix padding each */
 		}
 	}
 	
@@ -877,7 +879,7 @@
 		if (G.scene->r.stamp & R_STAMP_DRAW) {
 			/* Bottom left corner, leaving space for timing */
 			x = 1;
-			y = font_height+1;
+			y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */
 			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);
@@ -915,7 +917,7 @@
 			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);
-			x += text_width+text_pad;
+			x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
 		}
 	}
 





More information about the Bf-blender-cvs mailing list