forked from bartvdbraak/blender
render stamp drawing is now done everywhere - (not just when saving
images) separated stamp metadata and stamp draw functions.
This commit is contained in:
parent
47da2813d8
commit
7718b3d642
@ -268,7 +268,7 @@ void BMF_BitmapFont::DrawStringBuf(char *str, int posx, int posy, float *col, un
|
||||
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);
|
||||
|
@ -46,7 +46,8 @@ struct anim;
|
||||
/* 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);
|
||||
|
@ -777,15 +777,21 @@ void BKE_add_image_extension(char *string, int imtype)
|
||||
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;
|
||||
@ -793,10 +799,110 @@ void BKE_stamp(struct ImBuf *ibuf)
|
||||
#else
|
||||
char sdate[9];
|
||||
#endif /* WIN32 */
|
||||
|
||||
if (do_prefix) sprintf(stamp_data->file, "File %s", G.sce);
|
||||
else sprintf(stamp_data->file, "%s", G.sce);
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_NOTE) {
|
||||
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 (text, "%s", sdate);
|
||||
#else
|
||||
t = time (NULL);
|
||||
tl = localtime (&t);
|
||||
sprintf (text, "%04d-%02d-%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday);
|
||||
#endif /* WIN32 */
|
||||
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(text, marker->name);
|
||||
else strcpy(text, "<none>");
|
||||
|
||||
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);
|
||||
|
||||
if (!ibuf)
|
||||
if (s) {
|
||||
m = (int)(s / 60);
|
||||
s %= 60;
|
||||
|
||||
if (m) {
|
||||
h = (int)(m / 60);
|
||||
m %= 60;
|
||||
}
|
||||
}
|
||||
|
||||
if (G.scene->r.frs_sec < 100)
|
||||
sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f);
|
||||
else
|
||||
sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f);
|
||||
|
||||
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) {
|
||||
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_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';
|
||||
}
|
||||
|
||||
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);
|
||||
@ -820,158 +926,100 @@ void BKE_stamp(struct ImBuf *ibuf)
|
||||
|
||||
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 */
|
||||
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) {
|
||||
|
||||
if (stamp_data.file[0]) {
|
||||
/* 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 = height - font_height - 1; /* Also inits for everyone, notice padding pixel */
|
||||
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);
|
||||
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 */
|
||||
}
|
||||
/* Top left corner, below File */
|
||||
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);
|
||||
y -= font_height+2; /* Top and bottom 1 pix padding each */
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/* Top left corner, below File (or Note) */
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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+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);
|
||||
}
|
||||
/* Bottom left corner, leaving space for timing */
|
||||
if (stamp_data.marker[0]) {
|
||||
x = 1;
|
||||
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);
|
||||
}
|
||||
|
||||
/* Left bottom corner */
|
||||
if (stamp_data.time[0]) {
|
||||
x = 1;
|
||||
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);
|
||||
x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
|
||||
}
|
||||
|
||||
if (stamp_data.frame[0]) {
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.frame);
|
||||
/* Left bottom corner (after SMPTE if exists) */
|
||||
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);
|
||||
}
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_TIME) {
|
||||
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);
|
||||
|
||||
if (s) {
|
||||
m = (int)(s / 60);
|
||||
s %= 60;
|
||||
|
||||
if (m) {
|
||||
h = (int)(m / 60);
|
||||
m %= 60;
|
||||
}
|
||||
}
|
||||
|
||||
if (G.scene->r.frs_sec < 100)
|
||||
sprintf (infotext, "%02d:%02d:%02d.%02d", h, m, s, f);
|
||||
else
|
||||
sprintf (infotext, "%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 (stamp_data.camera[0]) {
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.camera);
|
||||
/* Center of bottom edge */
|
||||
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);
|
||||
}
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_FRAME) {
|
||||
sprintf (infotext, "%i", G.scene->r.cfra);
|
||||
IMB_imginfo_change_field (ibuf, "Frame", infotext);
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_DRAW) {
|
||||
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+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
|
||||
}
|
||||
|
||||
if (stamp_data.scene[0]) {
|
||||
text_width = BMF_GetStringWidth(font, stamp_data.scene);
|
||||
/* Bottom right corner */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_CAMERA) {
|
||||
sprintf(infotext, ((Camera *) G.scene->camera)->id.name+2);
|
||||
IMB_imginfo_change_field (ibuf, "Camera", infotext);
|
||||
void BKE_stamp_info(struct ImBuf *ibuf)
|
||||
{
|
||||
struct StampData stamp_data;
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_DRAW) {
|
||||
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+(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) {
|
||||
strcpy(infotext, G.scene->id.name+2);
|
||||
IMB_imginfo_change_field (ibuf, "Scene", infotext);
|
||||
|
||||
if (G.scene->r.stamp & R_STAMP_DRAW) {
|
||||
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+(text_pad/2), y, G.scene->r.fg_stamp, (unsigned char *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y);
|
||||
}
|
||||
}
|
||||
if (!ibuf) return;
|
||||
|
||||
/* fill all the data values, no prefix */
|
||||
stampdata(&stamp_data, 0);
|
||||
|
||||
if (stamp_data.file[0]) IMB_imginfo_change_field (ibuf, "File", stamp_data.file);
|
||||
if (stamp_data.note[0]) IMB_imginfo_change_field (ibuf, "Note", stamp_data.note);
|
||||
if (stamp_data.date[0]) IMB_imginfo_change_field (ibuf, "Date", stamp_data.date);
|
||||
if (stamp_data.marker[0]) IMB_imginfo_change_field (ibuf, "Marker", stamp_data.marker);
|
||||
if (stamp_data.time[0]) IMB_imginfo_change_field (ibuf, "Time", stamp_data.time);
|
||||
if (stamp_data.frame[0]) IMB_imginfo_change_field (ibuf, "Frame", stamp_data.frame);
|
||||
if (stamp_data.camera[0]) IMB_imginfo_change_field (ibuf, "Camera", stamp_data.camera);
|
||||
if (stamp_data.scene[0]) IMB_imginfo_change_field (ibuf, "Scene", stamp_data.scene);
|
||||
}
|
||||
|
||||
int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quality)
|
||||
@ -1035,8 +1083,8 @@ int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quali
|
||||
BLI_make_existing_file(name);
|
||||
|
||||
if(G.scene->r.scemode & R_STAMP_INFO)
|
||||
BKE_stamp(ibuf);
|
||||
|
||||
BKE_stamp_info(ibuf);
|
||||
|
||||
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
|
||||
if (ok == 0) {
|
||||
perror(name);
|
||||
|
@ -209,6 +209,7 @@ LIBEXPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf,
|
||||
|
||||
LIBEXPORT void IMB_rectfill(struct ImBuf *drect, float col[4]);
|
||||
LIBEXPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
|
||||
LIBEXPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
|
||||
|
||||
#endif /* IFF_H */
|
||||
|
||||
|
@ -547,6 +547,9 @@ void IMB_freezbuffloatImBuf(struct ImBuf * ibuf);
|
||||
void IMB_rectfill(struct ImBuf *drect, float col[4]);
|
||||
void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
|
||||
|
||||
/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
|
||||
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
|
||||
|
||||
/* defined in imginfo.c */
|
||||
int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field);
|
||||
|
||||
|
@ -521,18 +521,19 @@ void IMB_rectfill(struct ImBuf *drect, float col[4])
|
||||
#define FTOCHAR(val) (val<=0.0f ? 0: (val>=1.0f ? 255: (char)(255.99f*val)))
|
||||
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
|
||||
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
|
||||
void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2)
|
||||
|
||||
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int i, j;
|
||||
float a, ai;
|
||||
if ((!ibuf) || (!col))
|
||||
if ((!rect && !rectf) || (!col) || col[3]==0.0)
|
||||
return;
|
||||
|
||||
/* sanity checks for coords */
|
||||
CLAMP(x1, 0, ibuf->x);
|
||||
CLAMP(x2, 0, ibuf->x);
|
||||
CLAMP(y1, 0, ibuf->y);
|
||||
CLAMP(y2, 0, ibuf->y);
|
||||
CLAMP(x1, 0, width);
|
||||
CLAMP(x2, 0, width);
|
||||
CLAMP(y1, 0, height);
|
||||
CLAMP(y2, 0, height);
|
||||
|
||||
if (x1>x2) SWAP(int,x1,x2);
|
||||
if (y1>y2) SWAP(int,y1,y2);
|
||||
@ -541,38 +542,44 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i
|
||||
a = col[3];
|
||||
ai = 1-a;
|
||||
|
||||
if (ibuf->rect) {
|
||||
unsigned char *img, *pixel;
|
||||
|
||||
if (rect) {
|
||||
unsigned char *pixel;
|
||||
unsigned char chr, chg, chb;
|
||||
|
||||
chr = FTOCHAR(col[0]);
|
||||
chg = FTOCHAR(col[1]);
|
||||
chb = FTOCHAR(col[2]);
|
||||
float fr, fg, fb;
|
||||
|
||||
img = (unsigned char *) ibuf->rect;
|
||||
if (a == 1.0) {
|
||||
chr = FTOCHAR(col[0]);
|
||||
chg = FTOCHAR(col[1]);
|
||||
chb = FTOCHAR(col[2]);
|
||||
} else {
|
||||
fr = col[0]*a;
|
||||
fg = col[1]*a;
|
||||
fb = col[2]*a;
|
||||
}
|
||||
for (j = 0; j < y2-y1; j++) {
|
||||
for (i = 0; i < x2-x1; i++) {
|
||||
pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i));
|
||||
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));
|
||||
pixel = rect + 4 * (((y1 + j) * width) + (x1 + i));
|
||||
if (pixel >= rect && pixel < rect+ (4 * (width * height))) {
|
||||
if (a == 1.0) {
|
||||
pixel[0] = chr;
|
||||
pixel[1] = chg;
|
||||
pixel[2] = chb;
|
||||
} else {
|
||||
pixel[0] = (char)(fr + ((float)pixel[0]*ai));
|
||||
pixel[1] = (char)(fg + ((float)pixel[1]*ai));
|
||||
pixel[2] = (char)(fb + ((float)pixel[2]*ai));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ibuf->rect_float) {
|
||||
float *img, *pixel;
|
||||
img = ibuf->rect_float;
|
||||
if (rectf) {
|
||||
float *pixel;
|
||||
for (j = 0; j < y2-y1; j++) {
|
||||
for (i = 0; i < x2-x1; i++) {
|
||||
pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i));
|
||||
pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i));
|
||||
if (a == 1.0) {
|
||||
pixel[0] = col[0];
|
||||
pixel[1] = col[1];
|
||||
@ -586,3 +593,9 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (!ibuf) return;
|
||||
buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2);
|
||||
}
|
||||
|
@ -1998,8 +1998,17 @@ static void yafrayRender(Render *re)
|
||||
RE_Database_Free(re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* disable yafray */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
@ -2035,6 +2044,11 @@ static void do_render_all_options(Render *re)
|
||||
renderresult_add_names(re->result);
|
||||
|
||||
re->i.lastframetime= PIL_check_seconds_timer()- re->i.starttime;
|
||||
|
||||
/* stamp image info here */
|
||||
if(G.scene->r.scemode & R_STAMP_INFO && G.scene->r.stamp & R_STAMP_DRAW)
|
||||
renderresult_stampinfo();
|
||||
|
||||
re->stats_draw(&re->i);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user