[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12421] trunk/blender: render stamp drawing is now done everywhere - (not just when saving

Campbell Barton cbarton at metavr.com
Sun Oct 28 23:27:07 CET 2007


Revision: 12421
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12421
Author:   campbellbarton
Date:     2007-10-28 23:27:07 +0100 (Sun, 28 Oct 2007)

Log Message:
-----------
render stamp drawing is now done everywhere - (not just when saving 
images)
separated stamp metadata and stamp draw functions.

Modified Paths:
--------------
    trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp
    trunk/blender/source/blender/blenkernel/BKE_image.h
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/blenpluginapi/iff.h
    trunk/blender/source/blender/imbuf/IMB_imbuf.h
    trunk/blender/source/blender/imbuf/intern/rectop.c
    trunk/blender/source/blender/render/intern/source/pipeline.c

Modified: trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp
===================================================================
--- trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp	2007-10-28 19:12:08 UTC (rev 12420)
+++ trunk/blender/intern/bmfont/intern/BMF_BitmapFont.cpp	2007-10-28 22:27:07 UTC (rev 12421)
@@ -268,7 +268,7 @@
 				for (y = 0; y < cd.height; y++) {
 					unsigned char* chrRow = &m_fontData->bitmap_data[cd.data_offset + ((cd.width+7)/8)*y];
 					for (x = cd.xorig; x < cd.width; x++) {
-						pixel = buf + 4 * (((posy + y) * w) + (posx + x));
+						pixel = buf + 4 * (((posy + y - cd.yorig) * w) + (posx + x));
 						if ((pixel < max) && (pixel > buf)) {
 							int byteIdx = x/8;
 							int bitIdx = 7 - (x%8);

Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h	2007-10-28 19:12:08 UTC (rev 12420)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h	2007-10-28 22:27:07 UTC (rev 12421)
@@ -46,7 +46,8 @@
 /* call from library */
 void	free_image(struct Image *me);
 
-void	BKE_stamp(struct ImBuf *ibuf);
+void	BKE_stamp_info(struct ImBuf *ibuf);
+void	BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height);
 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	2007-10-28 19:12:08 UTC (rev 12420)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2007-10-28 22:27:07 UTC (rev 12421)
@@ -777,117 +777,68 @@
 	strcat(string, extension);
 }
 
-void BKE_stamp(struct ImBuf *ibuf)
+/* could allow access externally */
+typedef struct StampData {
+	char 	file[512];
+	char 	note[512];
+	char 	date[512];
+	char 	marker[512];
+	char 	time[512];
+	char 	frame[512];
+	char 	camera[512];
+	char 	scene[512];
+} StampData;
+
+static void stampdata(StampData *stamp_data, int do_prefix)
 {
-	char text[256], infotext[256];
-	int x=0, y=0, h, m, s, f;
-	int font_height;
-	int text_width;
-	int text_pad;
-	struct BMF_Font *font;
+	char text[256];
 	
-	
 #ifndef WIN32
 	struct tm *tl;
 	time_t t;
 #else
 	char sdate[9];
 #endif /* WIN32 */
-
-	if (!ibuf)
-		return;
 	
-	switch (G.scene->r.stamp_font_id) {
-	case 1: /* tiny */
-		font = BMF_GetFont(BMF_kHelveticaBold8);
-		break;
-	case 2: /* small */
-		font = BMF_GetFont(BMF_kHelveticaBold10);
-		break;
-	case 3: /* medium */
-		font = BMF_GetFont(BMF_kScreen12);
-		break;
-	case 0: /* large - default */
-		font = BMF_GetFont(BMF_kScreen15);
-		break;
-	case 4: /* huge */
-		font = BMF_GetFont(BMF_kHelveticaBold14);
-		break;
-	default:
-		font = NULL;
-		break;
-	}
+	if (do_prefix)		sprintf(stamp_data->file, "File %s", G.sce);
+	else				sprintf(stamp_data->file, "%s", G.sce);
 	
-	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, 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+2; /* Top and bottom 1 pix padding each */
-	}
-
 	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+2; /* Top and bottom 1 pix padding each */
-		}
+		if (do_prefix)		sprintf(stamp_data->note, "Note %s", G.scene->r.stamp_udata);
+		else				sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
+	} else {
+		stamp_data->note[0] = '\0';
 	}
 	
 	if (G.scene->r.stamp & R_STAMP_DATE) {
 #ifdef WIN32
 		_strdate (sdate);
-		sprintf (infotext, "%s", sdate);
+		sprintf (text, "%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);
+		sprintf (text, "%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 (do_prefix)		sprintf(stamp_data->date, "Date %s", text);
+		else				sprintf(stamp_data->date, "%s", text);
+	} else {
+		stamp_data->date[0] = '\0';
 	}
-
-
+	
 	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 (marker) strcpy(text, marker->name);
+		else 		strcpy(text, "<none>");
 		
-		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			/* Bottom left corner, leaving space for timing */
-			x = 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);
- 			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 (do_prefix)		sprintf(stamp_data->marker, "Marker %s", text);
+		else				sprintf(stamp_data->marker, "%s", text);
+	} else {
+		stamp_data->marker[0] = '\0';
 	}
-
+	
 	if (G.scene->r.stamp & R_STAMP_TIME) {
+		int h, m, s, f;
 		h= m= s= f= 0;
 		f = (int)(G.scene->r.cfra % G.scene->r.frs_sec);
 		s = (int)(G.scene->r.cfra / G.scene->r.frs_sec);
@@ -903,77 +854,174 @@
 		}
 
 		if (G.scene->r.frs_sec < 100)
-			sprintf (infotext, "%02d:%02d:%02d.%02d", h, m, s, f);
+			sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f);
 		else
-			sprintf (infotext, "%02d:%02d:%02d.%03d", h, m, s, f);
+			sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f);
 		
-		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+(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+2; /* Both sides have 1 pix additional padding each */
-		}
+		if (do_prefix)		sprintf(stamp_data->time, "Time %s", text);
+		else				sprintf(stamp_data->time, "%s", text);
+	} else {
+		stamp_data->time[0] = '\0';
 	}
-
+	
 	if (G.scene->r.stamp & R_STAMP_FRAME) {
-		sprintf (infotext, "%i", G.scene->r.cfra);
-		IMB_imginfo_change_field (ibuf, "Frame", infotext);
+		char format[32];
+		if (do_prefix)		sprintf(format, "Frame %%0%di\n", 1 + (int) log10(G.scene->r.efra));
+		else				sprintf(format, "%%0%di\n", 1 + (int) log10(G.scene->r.efra));
+		sprintf (stamp_data->frame, format, G.scene->r.cfra);
+	} else {
+		stamp_data->frame[0] = '\0';
+	}
 
-		if (G.scene->r.stamp & R_STAMP_DRAW) {
-			char format[32];
+	if (G.scene->r.stamp & R_STAMP_CAMERA) {
+		if (do_prefix)		sprintf(stamp_data->camera, "Camera %s", ((Camera *) G.scene->camera)->id.name+2);
+		else				sprintf(stamp_data->camera, "%s", ((Camera *) G.scene->camera)->id.name+2);
+	} else {
+		stamp_data->camera[0] = '\0';
+	}
 
-			/* 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+(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_SCENE) {
+		if (do_prefix)		sprintf(stamp_data->scene, "Camera %s", G.scene->id.name+2);
+		else				sprintf(stamp_data->scene, "%s", G.scene->id.name+2);
+	} else {
+		stamp_data->scene[0] = '\0';
 	}
+}
 
+void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height)
+{
+	struct StampData stamp_data;
+	
+	int x,y;
+	int font_height;
+	int text_width;
+	int text_pad;
+	struct BMF_Font *font;
+	
+	if (!rect && !rectf)
+		return;
+	
+	stampdata(&stamp_data, 1);
+	
+	switch (G.scene->r.stamp_font_id) {
+	case 1: /* tiny */
+		font = BMF_GetFont(BMF_kHelveticaBold8);
+		break;
+	case 2: /* small */
+		font = BMF_GetFont(BMF_kHelveticaBold10);
+		break;
+	case 3: /* medium */
+		font = BMF_GetFont(BMF_kScreen12);
+		break;
+	case 0: /* large - default */
+		font = BMF_GetFont(BMF_kScreen15);
+		break;
+	case 4: /* huge */
+		font = BMF_GetFont(BMF_kHelveticaBold14);
+		break;
+	default:
+		font = NULL;
+		break;
+	}
+	
+	font_height = BMF_GetFontHeight(font);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list