Index: source/blender/blenkernel/intern/image.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/image.c,v retrieving revision 1.50 diff -u -r1.50 image.c --- source/blender/blenkernel/intern/image.c 20 Dec 2006 17:57:41 -0000 1.50 +++ source/blender/blenkernel/intern/image.c 20 Dec 2006 19:29:13 -0000 @@ -798,7 +798,7 @@ BLI_make_existing_file(name); - ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); + ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat | IB_userdata); if (ok == 0) { perror(name); } Index: source/blender/imbuf/IMB_imbuf_types.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/imbuf/IMB_imbuf_types.h,v retrieving revision 1.24 diff -u -r1.24 IMB_imbuf_types.h --- source/blender/imbuf/IMB_imbuf_types.h 20 Dec 2006 17:57:43 -0000 1.24 +++ source/blender/imbuf/IMB_imbuf_types.h 20 Dec 2006 19:29:13 -0000 @@ -148,6 +148,8 @@ #define IB_rectfloat (1 << 15) #define IB_zbuffloat (1 << 16) #define IB_multilayer (1 << 17) +#define IB_userdata (1 << 18) + /* * The bit flag is stored in the ImBuf.ftype variable. Index: source/blender/imbuf/intern/allocimbuf.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/imbuf/intern/allocimbuf.c,v retrieving revision 1.14 diff -u -r1.14 allocimbuf.c --- source/blender/imbuf/intern/allocimbuf.c 20 Dec 2006 17:57:43 -0000 1.14 +++ source/blender/imbuf/intern/allocimbuf.c 20 Dec 2006 19:29:14 -0000 @@ -419,7 +419,7 @@ return (ibuf); } -/* does no zbuffers? */ +/* now does zbuffers and userdata (for stampinfo) */ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) { struct ImBuf *ibuf2, tbuf; @@ -431,6 +431,9 @@ if (ibuf1->rect) flags |= IB_rect; if (ibuf1->rect_float) flags |= IB_rectfloat; if (ibuf1->planes) flags |= IB_planes; + if (ibuf1->zbuf) flags |= IB_zbuf; + if (ibuf1->zbuf_float) flags |= IB_zbuffloat; + if (ibuf1->userdata) flags |= IB_userdata; x = ibuf1->x; y = ibuf1->y; @@ -444,6 +447,19 @@ if (flags & IB_rectfloat) memcpy(ibuf2->rect_float, ibuf1->rect_float, 4 * x * y * sizeof(float)); + + if (flags & IB_zbuf) + memcpy(ibuf2->zbuf, ibuf1->zbuf, x * y * sizeof(int)); + + if (flags & IB_zbuffloat) + memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, x * y * sizeof(float)); + + if (flags & IB_userdata){ + if ( (ibuf2->userdata = MEM_mallocN(strlen(ibuf1->userdata)+1, "imb_userdata")) ){ + memcpy(ibuf2->userdata, ibuf1->userdata,strlen(ibuf1->userdata)+1); + ibuf2->mall |= IB_userdata; + } + } if (flags & IB_planes) memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int)); @@ -467,11 +483,12 @@ tbuf.planes = ibuf2->planes; tbuf.cmap = ibuf2->cmap; tbuf.encodedbuffer = ibuf2->encodedbuffer; - tbuf.zbuf= NULL; - tbuf.zbuf_float= NULL; + tbuf.zbuf=ibuf2->zbuf; + tbuf.zbuf_float=ibuf2->zbuf_float; + tbuf.userdata=ibuf2->userdata; for(a=0; amall; tbuf.c_handle = 0; Index: source/blender/imbuf/intern/jpeg.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/imbuf/intern/jpeg.c,v retrieving revision 1.12 diff -u -r1.12 jpeg.c --- source/blender/imbuf/intern/jpeg.c 28 Feb 2006 23:58:17 -0000 1.12 +++ source/blender/imbuf/intern/jpeg.c 20 Dec 2006 19:29:14 -0000 @@ -243,12 +243,14 @@ int row_stride; int x, y, depth, r, g, b, k; struct ImBuf * ibuf = 0; - uchar * rect; - + uchar * rect, *stampstr; + jpeg_saved_marker_ptr marker; + /* install own app1 handler */ ibuf_ftype = 0; jpeg_set_marker_processor(cinfo, 0xe1, handle_app1); cinfo->dct_method = JDCT_FLOAT; + jpeg_save_markers(cinfo, JPEG_COM, 0xffff); if (jpeg_read_header(cinfo, FALSE) == JPEG_HEADER_OK) { x = cinfo->image_width; @@ -335,6 +337,22 @@ } } } + /**framestampinfo***/ + marker = cinfo->marker_list; + while (marker) { + if (marker->marker == JPEG_COM) { + if (strncmp((char*)marker->data, "Made with Blender", 17) == 0){ + stampstr = MEM_mallocN(marker->data_length, "framestampinfo"); + memcpy(stampstr,marker->data,marker->data_length); + ibuf->userdata=(uchar *)stampstr; + ibuf->mall |= IB_userdata; + ibuf->flags |= IB_userdata; + break; + } + } + marker = marker->next; + } + jpeg_finish_decompress(cinfo); } @@ -400,6 +418,12 @@ memcpy(neogeo + 6, &ibuf_ftype, 4); jpeg_write_marker(cinfo, 0xe1, (JOCTET*) neogeo, 10); + + if(ibuf->userdata) jpeg_write_marker(cinfo, JPEG_COM, (JOCTET*) ibuf->userdata,strlen(ibuf->userdata)+1); + else{ + sprintf(neogeo,"blender: info stamp test\nno userdata to save\n"); + jpeg_write_marker(cinfo, JPEG_COM, (JOCTET*) neogeo,strlen(neogeo)+1); + } row_pointer[0] = mallocstruct(JSAMPLE, Index: source/blender/imbuf/intern/png.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/imbuf/intern/png.c,v retrieving revision 1.5 diff -u -r1.5 png.c --- source/blender/imbuf/intern/png.c 19 Mar 2005 21:08:10 -0000 1.5 +++ source/blender/imbuf/intern/png.c 20 Dec 2006 19:29:15 -0000 @@ -215,6 +215,17 @@ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + /*********stampinfo proof of concept**************/ + if(ibuf->userdata){ + png_text imginfo[1]; + int num_text = 1; + + imginfo[0].compression = PNG_TEXT_COMPRESSION_NONE; + imginfo[0].key = "blender"; + imginfo[0].text = ibuf->userdata; + png_set_text(png_ptr, info_ptr, imginfo, num_text); + } // write the file header information png_write_info(png_ptr, info_ptr); @@ -264,6 +275,11 @@ unsigned char *from, *to; int i, bytesperpixel; + /*for stampinfo*/ + png_text* text_chunks; + unsigned char *stampstr; + int count = 0; + if (imb_is_a_png(mem) == 0) return(0); @@ -403,6 +419,19 @@ to += 4; from++; } break; + } + + /***get stampinfo****/ + count = png_get_text(png_ptr, info_ptr, &text_chunks, NULL); + for(i = 0; i < count; i++) { + if (strncmp((char*)text_chunks[i].key, "blender", 7) == 0){ + stampstr = MEM_mallocN(strlen(text_chunks[i].text)+1, "framestampinfo"); + memcpy(stampstr,text_chunks[i].text,strlen(text_chunks[i].text)+1); + ibuf->userdata=(uchar *)stampstr; + ibuf->mall |= IB_userdata; + ibuf->flags |= IB_userdata; + break; + } } png_read_end(png_ptr, info_ptr); Index: source/blender/imbuf/intern/writeimage.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/imbuf/intern/writeimage.c,v retrieving revision 1.18 diff -u -r1.18 writeimage.c --- source/blender/imbuf/intern/writeimage.c 12 Mar 2006 14:11:22 -0000 1.18 +++ source/blender/imbuf/intern/writeimage.c 20 Dec 2006 19:29:15 -0000 @@ -36,7 +36,13 @@ #include #endif +#include +#include "DNA_object_types.h" +#include "DNA_ID.h" +#include "DNA_scene_types.h" #include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_blender.h" #include "BLI_blenlib.h" #include "imbuf.h" @@ -72,9 +78,32 @@ { short ok=TRUE,delpl=FALSE; int file = -1; - + char infostr[2048],timestr[30]; /***infostr may need to be larger when optional text is included***/ + size_t i; + struct tm tim; + time_t now; + if (ibuf==0) return (FALSE); ibuf->flags = flags; + + /*******setup info for saving*********/ + if(!ibuf->userdata){ + now = time(NULL); + tim = *(localtime(&now)); + i = strftime(timestr,30,"%Y-%m-%d %H:%M:%S",&tim); + + sprintf(infostr,"Made with Blender %d.%d\nFile: %s\nScene: %s\nCamera: %s\nDate: %s\nOrig size: %d x %d\nFrame: %i\nFramerate: %i frs/sec\n", + G.version, BLENDER_SUBVERSION, G.main->name, G.scene->id.name+2, G.scene->camera->id.name+2, + timestr, ibuf->x, ibuf->y, G.scene->r.cfra, G.scene->r.frs_sec); + + /*****put info into imbuf for image formats that can save it as metadata******/ + ibuf->userdata = MEM_mallocN(strlen(infostr)+1, "imb_userdata"); + if(ibuf->userdata){ + memcpy(ibuf->userdata, infostr,strlen(infostr)+1); + ibuf->mall |= IB_userdata; + ibuf->flags |= IB_userdata; + } + } /* Put formats that take a filename here */ if (IS_jpg(ibuf)) { Index: source/blender/python/api2_2x/Image.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Image.c,v retrieving revision 1.60 diff -u -r1.60 Image.c --- source/blender/python/api2_2x/Image.c 20 Dec 2006 17:57:45 -0000 1.60 +++ source/blender/python/api2_2x/Image.c 20 Dec 2006 19:29:18 -0000 @@ -80,6 +80,7 @@ /*****************************************************************************/ static PyObject *Image_getName( BPy_Image * self ); static PyObject *Image_getFilename( BPy_Image * self ); +static PyObject *Image_getUserdata( BPy_Image * self ); static PyObject *Image_getSize( BPy_Image * self ); static PyObject *Image_getDepth( BPy_Image * self ); static PyObject *Image_getXRep( BPy_Image * self ); @@ -131,6 +132,8 @@ "() - Return Image object name"}, {"getFilename", ( PyCFunction ) Image_getFilename, METH_NOARGS, "() - Return Image object filename"}, + {"getUserdata", ( PyCFunction ) Image_getUserdata, METH_NOARGS, + "() - Return Image object userdata"}, {"getSize", ( PyCFunction ) Image_getSize, METH_NOARGS, "() - Return Image object [width, height] dimension in pixels"}, {"getDepth", ( PyCFunction ) Image_getDepth, METH_NOARGS, @@ -826,6 +829,20 @@ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "couldn't get Image.filename attribute" ) ); +} + +static PyObject *Image_getUserdata( BPy_Image * self ) +{ + PyObject *attr; + ImBuf *ibuf = BKE_image_get_ibuf(self->image, NULL); + char *userdata = ibuf->userdata; + + if(userdata) attr = PyString_FromString( userdata ); + else attr = PyString_FromString("no render data available"); + if( attr ) return attr; + + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "couldn't get Image.userdata attribute" ); } static PyObject *Image_getSize( BPy_Image * self )