forked from bartvdbraak/blender
- pass the camera to the render stamp function.
- add BKE_write_ibuf_stamp() since saving environment maps & screen shots shouldn't have stamp.
This commit is contained in:
parent
abcdf9573a
commit
c4c22d4e9f
@ -44,14 +44,16 @@ struct ImBuf;
|
||||
struct Tex;
|
||||
struct anim;
|
||||
struct Scene;
|
||||
struct Object;
|
||||
|
||||
/* call from library */
|
||||
void free_image(struct Image *me);
|
||||
|
||||
void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf);
|
||||
void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels);
|
||||
void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf);
|
||||
void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
|
||||
int BKE_alphatest_ibuf(struct ImBuf *ibuf);
|
||||
int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
||||
int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
||||
int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
||||
void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames);
|
||||
int BKE_add_image_extension(char *string, int imtype);
|
||||
int BKE_ftype_to_imtype(int ftype);
|
||||
|
@ -1905,7 +1905,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
|
||||
}
|
||||
|
||||
/* ensure cameras are set as if they are on a visible layer, because
|
||||
they ared still used for rendering or setting the camera view */
|
||||
* they ared still used for rendering or setting the camera view
|
||||
*
|
||||
* XXX, this wont work for local view / unlocked camera's */
|
||||
if(sce->camera) {
|
||||
node= dag_get_node(sce->theDag, sce->camera);
|
||||
node->scelay |= lay;
|
||||
|
@ -880,7 +880,7 @@ typedef struct StampData {
|
||||
char rendertime[64];
|
||||
} StampData;
|
||||
|
||||
static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
|
||||
static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix)
|
||||
{
|
||||
char text[256];
|
||||
struct tm *tl;
|
||||
@ -959,14 +959,14 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
|
||||
}
|
||||
|
||||
if (scene->r.stamp & R_STAMP_CAMERA) {
|
||||
BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", scene->camera ? scene->camera->id.name+2 : "<none>");
|
||||
BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", camera ? camera->id.name+2 : "<none>");
|
||||
} else {
|
||||
stamp_data->camera[0] = '\0';
|
||||
}
|
||||
|
||||
if (scene->r.stamp & R_STAMP_CAMERALENS) {
|
||||
if (scene->camera && scene->camera->type == OB_CAMERA) {
|
||||
BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)scene->camera->data)->lens);
|
||||
if (camera && camera->type == OB_CAMERA) {
|
||||
BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens);
|
||||
}
|
||||
else strcpy(text, "<none>");
|
||||
|
||||
@ -1006,7 +1006,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels)
|
||||
void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels)
|
||||
{
|
||||
struct StampData stamp_data;
|
||||
float w, h, pad;
|
||||
@ -1017,7 +1017,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
|
||||
if (!rect && !rectf)
|
||||
return;
|
||||
|
||||
stampdata(scene, &stamp_data, 1);
|
||||
stampdata(scene, camera, &stamp_data, 1);
|
||||
|
||||
/* TODO, do_versions */
|
||||
if(scene->r.stamp_font_id < 8)
|
||||
@ -1199,14 +1199,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
|
||||
BLF_buffer(mono, NULL, NULL, 0, 0, 0);
|
||||
}
|
||||
|
||||
void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf)
|
||||
void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf)
|
||||
{
|
||||
struct StampData stamp_data;
|
||||
|
||||
if (!ibuf) return;
|
||||
|
||||
/* fill all the data values, no prefix */
|
||||
stampdata(scene, &stamp_data, 0);
|
||||
stampdata(scene, camera, &stamp_data, 0);
|
||||
|
||||
if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file);
|
||||
if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note);
|
||||
@ -1244,7 +1244,7 @@ int BKE_alphatest_ibuf(ImBuf *ibuf)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality)
|
||||
int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality)
|
||||
{
|
||||
int ok;
|
||||
(void)subimtype; /* quies unused warnings */
|
||||
@ -1339,9 +1339,6 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int
|
||||
}
|
||||
|
||||
BLI_make_existing_file(name);
|
||||
|
||||
if(scene && scene->r.stamp & R_STAMP_ALL)
|
||||
BKE_stamp_info(scene, ibuf);
|
||||
|
||||
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
|
||||
if (ok == 0) {
|
||||
@ -1351,6 +1348,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality)
|
||||
{
|
||||
if(scene && scene->r.stamp & R_STAMP_ALL)
|
||||
BKE_stamp_info(scene, camera, ibuf);
|
||||
|
||||
return BKE_write_ibuf(ibuf, name, imtype, subimtype, quality);
|
||||
}
|
||||
|
||||
|
||||
void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames)
|
||||
{
|
||||
|
@ -114,6 +114,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
View3D *v3d= oglrender->v3d;
|
||||
RegionView3D *rv3d= oglrender->rv3d;
|
||||
RenderResult *rr;
|
||||
Object *camera= NULL;
|
||||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
float winmat[4][4];
|
||||
@ -140,7 +141,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
/* render 3d view */
|
||||
if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
|
||||
/*int is_ortho= scene->r.mode & R_ORTHO;*/
|
||||
RE_GetCameraWindow(oglrender->re, v3d->camera, scene->r.cfra, winmat);
|
||||
camera= v3d->camera;
|
||||
RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat);
|
||||
|
||||
}
|
||||
else {
|
||||
@ -191,6 +193,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
/* shouldnt suddenly give errors mid-render but possible */
|
||||
char err_out[256]= "unknown";
|
||||
ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, err_out);
|
||||
camera= scene->camera;
|
||||
|
||||
if(ibuf_view) {
|
||||
memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
|
||||
@ -204,7 +207,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
/* rr->rectf is now filled with image data */
|
||||
|
||||
if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
|
||||
BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4);
|
||||
BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
|
||||
|
||||
RE_ReleaseResult(oglrender->re);
|
||||
|
||||
@ -218,7 +221,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
char name[FILE_MAX];
|
||||
int ok;
|
||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
|
||||
ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); /* no need to stamp here */
|
||||
if(ok) printf("OpenGL Render written to '%s'\n", name);
|
||||
else printf("OpenGL Render failed to write '%s'\n", name);
|
||||
}
|
||||
@ -387,6 +390,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
|
||||
char name[FILE_MAXDIR+FILE_MAXFILE];
|
||||
int ok= 0;
|
||||
const short view_context= (oglrender->v3d != NULL);
|
||||
Object *camera= NULL;
|
||||
|
||||
/* update animated image textures for gpu, etc,
|
||||
* call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
|
||||
@ -409,12 +413,17 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
|
||||
if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
|
||||
/* since scene_update_for_newframe() is used rather
|
||||
* then ED_update_for_newframe() the camera needs to be set */
|
||||
if(scene_camera_switch_update(scene))
|
||||
if(scene_camera_switch_update(scene)) {
|
||||
oglrender->v3d->camera= scene->camera;
|
||||
}
|
||||
|
||||
camera= oglrender->v3d->camera;
|
||||
}
|
||||
}
|
||||
else {
|
||||
scene_camera_switch_update(scene);
|
||||
|
||||
camera= scene->camera;
|
||||
}
|
||||
|
||||
/* render into offscreen buffer */
|
||||
@ -433,7 +442,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
|
||||
ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
|
||||
if(ok==0) {
|
||||
printf("Write error: cannot save %s\n", name);
|
||||
|
@ -874,7 +874,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int
|
||||
/* to save, we first get absolute path */
|
||||
BLI_path_abs(str, G.main->name);
|
||||
|
||||
if (BKE_write_ibuf(scene, ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) {
|
||||
if (BKE_write_ibuf(ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) {
|
||||
retval = OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
|
@ -95,7 +95,7 @@ static int screenshot_exec(bContext *C, wmOperator *op)
|
||||
ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
|
||||
ibuf->rect= scd->dumprect;
|
||||
|
||||
BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
@ -280,7 +280,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
|
||||
BKE_makepicstring(name, rd.pic, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE);
|
||||
|
||||
ibuf->rect= sj->dumprect;
|
||||
ok= BKE_write_ibuf(sj->scene, ibuf, name, rd.imtype, rd.subimtype, rd.quality);
|
||||
ok= BKE_write_ibuf(ibuf, name, rd.imtype, rd.subimtype, rd.quality);
|
||||
|
||||
if(ok==0) {
|
||||
printf("Write error: cannot save %s\n", name);
|
||||
|
@ -925,7 +925,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
|
||||
}
|
||||
BKE_image_release_renderresult(scene, ima);
|
||||
}
|
||||
else if (BKE_write_ibuf(scene, ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) {
|
||||
else if (BKE_write_ibuf(ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) {
|
||||
ok= TRUE;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
|
||||
const float dither_back= ibuf->dither;
|
||||
ibuf->depth= scene->r.planes;
|
||||
ibuf->dither= scene->r.dither_intensity;
|
||||
if (!BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) {
|
||||
if (!BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path);
|
||||
}
|
||||
ibuf->depth= imb_depth_back;
|
||||
|
@ -78,7 +78,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
|
||||
|
||||
BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION), TRUE);
|
||||
|
||||
if(0 == BKE_write_ibuf((Scene *)node->id, ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality))
|
||||
if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality))
|
||||
printf("Cannot save Node File Output to %s\n", string);
|
||||
else
|
||||
printf("Saved: %s\n", string);
|
||||
|
@ -2479,14 +2479,13 @@ static void do_render_composite_fields_blur_3d(Render *re)
|
||||
re->display_draw(re->ddh, re->result, NULL);
|
||||
}
|
||||
|
||||
static void renderresult_stampinfo(Scene *scene)
|
||||
static void renderresult_stampinfo(Render *re)
|
||||
{
|
||||
RenderResult rres;
|
||||
Render *re= RE_GetRender(scene->id.name);
|
||||
|
||||
/* this is the basic trick to get the displayed float or char rect from render result */
|
||||
RE_AcquireResultImage(re, &rres);
|
||||
BKE_stamp_buf(scene, (unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4);
|
||||
BKE_stamp_buf(re->scene, RE_GetCamera(re), (unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4);
|
||||
RE_ReleaseResultImage(re);
|
||||
}
|
||||
|
||||
@ -2645,7 +2644,7 @@ static void do_render_all_options(Render *re)
|
||||
|
||||
/* stamp image info here */
|
||||
if((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) {
|
||||
renderresult_stampinfo(re->scene);
|
||||
renderresult_stampinfo(re);
|
||||
re->display_draw(re->ddh, re->result, NULL);
|
||||
}
|
||||
}
|
||||
@ -2938,6 +2937,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
|
||||
{
|
||||
char name[FILE_MAX];
|
||||
RenderResult rres;
|
||||
Object *camera= RE_GetCamera(re);
|
||||
int ok= 1;
|
||||
|
||||
RE_AcquireResultImage(re, &rres);
|
||||
@ -2992,7 +2992,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
|
||||
}
|
||||
}
|
||||
|
||||
ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
|
||||
if(ok==0) {
|
||||
printf("Render error: cannot save %s\n", name);
|
||||
@ -3005,7 +3005,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
|
||||
name[strlen(name)-4]= 0;
|
||||
BKE_add_image_extension(name, R_JPEG90);
|
||||
ibuf->depth= 24;
|
||||
BKE_write_ibuf(scene, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality);
|
||||
BKE_write_ibuf_stamp(scene, camera, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality);
|
||||
printf("\nSaved: %s", name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user