Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-01-24 01:05:47 +0300
committerTon Roosendaal <ton@blender.org>2006-01-24 01:05:47 +0300
commit042d612df219c8f6a29afa235537380f227b5684 (patch)
tree310a2c859b99c559115bbcda0aa70f2543bf962c /source/blender/src/writeimage.c
parent5668480c99001a617fd59a2383deb858195ffb26 (diff)
Giant commit!
A full detailed description of this will be done later... is several days of work. Here's a summary: Render: - Full cleanup of render code, removing *all* globals and bad level calls all over blender. Render module is now not called abusive anymore - API-fied calls to rendering - Full recode of internal render pipeline. Is now rendering tiles by default, prepared for much smarter 'bucket' render later. - Each thread now can render a full part - Renders were tested with 4 threads, goes fine, apart from some lookup tables in softshadow and AO still - Rendering is prepared to do multiple layers and passes - No single 32 bits trick in render code anymore, all 100% floats now. Writing images/movies - moved writing images to blender kernel (bye bye 'schrijfplaatje'!) - made a new Movie handle system, also in kernel. This will enable much easier use of movies in Blender PreviewRender: - Using new render API, previewrender (in buttons) now uses regular render code to generate images. - new datafile 'preview.blend.c' has the preview scenes in it - previews get rendered in exact displayed size (1 pixel = 1 pixel) 3D Preview render - new; press Pkey in 3d window, for a panel that continuously renders (pkey is for games, i know... but we dont do that in orange now!) - this render works nearly identical to buttons-preview render, so it stops rendering on any event (mouse, keyboard, etc) - on moving/scaling the panel, the render code doesn't recreate all geometry - same for shifting/panning view - all other operations (now) regenerate the full render database still. - this is WIP... but big fun, especially for simple scenes! Compositor - Using same node system as now in use for shaders, you can composit images - works pretty straightforward... needs much more options/tools and integration with rendering still - is not threaded yet, nor is so smart to only recalculate changes... will be done soon! - the "Render Result" node will get all layers/passes as output sockets - The "Output" node renders to a builtin image, which you can view in the Image window. (yes, output nodes to render-result, and to files, is on the list!) The Bad News - "Unified Render" is removed. It might come back in some stage, but this system should be built from scratch. I can't really understand this code... I expect it is not much needed, especially with advanced layer/passes control - Panorama render, Field render, Motion blur, is not coded yet... (I had to recode every single feature in render, so...!) - Lens Flare is also not back... needs total revision, might become composit effect though (using zbuffer for visibility) - Part render is gone! (well, thats obvious, its default now). - The render window is only restored with limited functionality... I am going to check first the option to render to a Image window, so Blender can become a true single-window application. :) For example, the 'Spare render buffer' (jkey) doesnt work. - Render with border, now default creates a smaller image - No zbuffers are written yet... on the todo! - Scons files and MSVC will need work to get compiling again OK... thats what I can quickly recall. Now go compiling!
Diffstat (limited to 'source/blender/src/writeimage.c')
-rw-r--r--source/blender/src/writeimage.c180
1 files changed, 124 insertions, 56 deletions
diff --git a/source/blender/src/writeimage.c b/source/blender/src/writeimage.c
index 4f1224eabff..1e89c8e8bba 100644
--- a/source/blender/src/writeimage.c
+++ b/source/blender/src/writeimage.c
@@ -30,77 +30,35 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" // ImBuf{}
+#include "BLI_blenlib.h"
+
#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
#include "DNA_texture_types.h" // EnvMap{}
#include "DNA_image_types.h" // Image{}
#include "BKE_global.h" // struct G
+#include "BKE_image.h"
#include "BKE_utildefines.h" // ELEM
+#include "BIF_screen.h" // waitcursor
+#include "BIF_toolbox.h"
#include "BIF_writeimage.h"
-#include "render.h" // RE_make_existing_file, R. stuff
-
-int BIF_write_ibuf(ImBuf *ibuf, char *name)
-{
- int ok;
-
- /* to be used for e.g. envmap, not rendered images */
-
- if(G.scene->r.imtype== R_IRIS) ibuf->ftype= IMAGIC;
- else if ((G.scene->r.imtype==R_RADHDR)) {
- ibuf->ftype= RADHDR;
- }
- else if ((G.scene->r.imtype==R_PNG)) {
- ibuf->ftype= PNG;
- }
- else if ((G.scene->r.imtype==R_BMP)) {
- ibuf->ftype= BMP;
- }
- else if ((G.have_libtiff) && (G.scene->r.imtype==R_TIFF)) {
- ibuf->ftype= TIF;
- }
-#ifdef WITH_OPENEXR
- else if (G.scene->r.imtype==R_OPENEXR) {
- ibuf->ftype= OPENEXR;
- if(G.scene->r.subimtype & R_OPENEXR_HALF)
- ibuf->ftype |= OPENEXR_HALF;
- ibuf->ftype |= (G.scene->r.quality & OPENEXR_COMPRESS);
- }
-#endif
- else if ((G.scene->r.imtype==R_TARGA) || (G.scene->r.imtype==R_PNG)) {
- // fall back to Targa if PNG writing is not supported
- ibuf->ftype= TGA;
- }
- else if(G.scene->r.imtype==R_RAWTGA) {
- ibuf->ftype= RAWTGA;
- }
- else if(G.scene->r.imtype==R_HAMX) {
- ibuf->ftype= AN_hamx;
- }
- else if ELEM(G.scene->r.imtype, R_JPEG90, R_MOVIE) {
- if(G.scene->r.quality < 10) G.scene->r.quality= 90;
-
- ibuf->ftype= JPG|G.scene->r.quality;
- }
- else ibuf->ftype= TGA;
-
- RE_make_existing_file(name);
-
- ok = IMB_saveiff(ibuf, name, IB_rect);
- if (ok == 0) {
- perror(name);
- }
-
- return(ok);
-}
+#include "BSE_filesel.h"
+#include "RE_pipeline.h"
/* ------------------------------------------------------------------------- */
+
void BIF_save_envmap(EnvMap *env, char *str)
{
ImBuf *ibuf;
@@ -120,6 +78,116 @@ void BIF_save_envmap(EnvMap *env, char *str)
IMB_rectcpy(ibuf, env->cube[4]->ibuf, dx, dx, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[5]->ibuf, 2*dx, dx, 0, 0, dx, dx);
- BIF_write_ibuf(ibuf, str);
+ BKE_write_ibuf(ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality);
IMB_freeImBuf(ibuf);
}
+
+
+/* callback for fileselect to save rendered image, renderresult was checked to exist */
+static void save_rendered_image_cb(char *name)
+{
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+
+ if(BLI_testextensie(str,".blend")) {
+ error("Wrong filename");
+ return;
+ }
+
+ /* BKE_add_image_extension() checks for if extension was already set */
+ if(G.scene->r.scemode & R_EXTENSION)
+ if(strlen(name)<FILE_MAXDIR+FILE_MAXFILE-5)
+ BKE_add_image_extension(name, G.scene->r.imtype);
+
+ strcpy(str, name);
+ BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
+
+ if(saveover(str)) {
+ RenderResult *rr= RE_GetResult(RE_GetRender("Render"));
+ RenderLayer *rl= rr->layers.first;
+ ImBuf *ibuf;
+
+ waitcursor(1); /* from screen.c */
+
+ ibuf= IMB_allocImBuf(rr->rectx, rr->recty, G.scene->r.planes, 0, 0);
+ ibuf->rect= rr->rect32;
+ ibuf->rect_float= rl->rectf;
+ ibuf->zbuf_float= rl->rectz;
+
+ BKE_write_ibuf(ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality);
+ IMB_freeImBuf(ibuf); /* imbuf knows rects are not part of ibuf */
+
+ strcpy(G.ima, name);
+
+ waitcursor(0);
+ }
+}
+
+void save_image_filesel_str(char *str)
+{
+ switch(G.scene->r.imtype) {
+ case R_RADHDR:
+ strcpy(str, "Save Radiance HDR");
+ break;
+ case R_PNG:
+ strcpy(str, "Save PNG");
+ break;
+ case R_BMP:
+ strcpy(str, "Save BMP");
+ break;
+ case R_TIFF:
+ if (G.have_libtiff)
+ strcpy(str, "Save TIFF");
+ break;
+#ifdef WITH_OPENEXR
+ case R_OPENEXR:
+ strcpy(str, "Save OpenEXR");
+ break;
+#endif
+ case R_RAWTGA:
+ strcpy(str, "Save Raw Targa");
+ break;
+ case R_IRIS:
+ strcpy(str, "Save IRIS");
+ break;
+ case R_IRIZ:
+ strcpy(str, "Save IRIS");
+ break;
+ case R_HAMX:
+ strcpy(str, "Save HAMX");
+ break;
+ case R_JPEG90:
+ case R_MOVIE:
+ case R_AVICODEC:
+ case R_AVIRAW:
+ case R_AVIJPEG:
+ strcpy(str, "Save JPEG");
+ break;
+
+ case R_TARGA: /* default targa */
+ default:
+ strcpy(str, "Save Targa");
+ break;
+ }
+}
+
+/* calls fileselect */
+void BIF_save_rendered_image_fs(void)
+{
+ RenderResult *rr= RE_GetResult(RE_GetRender("Render"));
+
+ if(!rr) {
+ error("No image rendered");
+ } else {
+ char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
+
+ if(G.ima[0]==0) {
+ strcpy(dir, G.sce);
+ BLI_splitdirstring(dir, str);
+ strcpy(G.ima, dir);
+ }
+
+ save_image_filesel_str(str);
+ activate_fileselect(FILE_SPECIAL, str, G.ima, save_rendered_image_cb);
+ }
+}
+