render async tile to separate tempfile
authorTero Marttila <terom@fixme.fi>
Thu, 31 Dec 2009 17:05:46 +0200
changeset 23 9fd50fc1d223
parent 22 811c88041c06
child 24 0d319520916e
render async tile to separate tempfile
src/util/main.c
--- a/src/util/main.c	Thu Dec 31 17:01:38 2009 +0200
+++ b/src/util/main.c	Thu Dec 31 17:05:46 2009 +0200
@@ -184,9 +184,28 @@
 
         // render tile?
         if (ti.width && ti.height) {
-            log_debug("Async render tile %zux%zu@(%zu,%zu) -> stdout", ti.width, ti.height, ti.x, ti.y);
+            char tmp_name[] = "pt-tile-XXXXXX";
+            int fd;
+            FILE *out;
+            
+            // temporary file for output
+            if ((fd = mkstemp(tmp_name)) < 0) {
+                log_errno("mkstemp");
+                
+                continue;
+            }
 
-            if ((err = pt_image_tile_async(image, &ti, stdout)))
+            // open out
+            if ((out = fdopen(fd, "w")) == NULL) {
+                log_errno("fdopen");
+
+                continue;
+            }
+
+            // render
+            log_debug("Async render tile %zux%zu@(%zu,%zu) -> %s", ti.width, ti.height, ti.x, ti.y, tmp_name);
+
+            if ((err = pt_image_tile_async(image, &ti, out)))
                 log_errno("pt_image_tile: %s: %s", img_path, pt_strerror(err));
         }