Revision: 56729
          http://sourceforge.net/p/brlcad/code/56729
Author:   mohitdaga
Date:     2013-08-09 21:38:17 +0000 (Fri, 09 Aug 2013)
Log Message:
-----------
Now bw_save and pix_save can write images to stdout.

Modified Paths:
--------------
    brlcad/trunk/src/libicv/bw.c
    brlcad/trunk/src/libicv/pix.c

Modified: brlcad/trunk/src/libicv/bw.c
===================================================================
--- brlcad/trunk/src/libicv/bw.c        2013-08-09 21:26:34 UTC (rev 56728)
+++ brlcad/trunk/src/libicv/bw.c        2013-08-09 21:38:17 UTC (rev 56729)
@@ -57,9 +57,11 @@
     }
     data =  data2uchar(bif);
     size = (size_t) bif->height*bif->width;
-    fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, WRMODE);
-    if (fd < 0) {
-       bu_log("Unable to open the file\n");
+    
+    if(filename==NULL)
+       fd = 1; /* for stdout */
+    else if ((fd = open(filename, O_RDONLY, WRMODE)) < 0) {
+       bu_log("bw_save: Cannot open file for saving\n");
        return -1;
     }
 

Modified: brlcad/trunk/src/libicv/pix.c
===================================================================
--- brlcad/trunk/src/libicv/pix.c       2013-08-09 21:26:34 UTC (rev 56728)
+++ brlcad/trunk/src/libicv/pix.c       2013-08-09 21:38:17 UTC (rev 56729)
@@ -54,9 +54,16 @@
        bu_log("pix_save : Color Space conflict");
        return -1;
     }
+    
+    if(filename==NULL)
+       fd = 1; /* for stdout */
+    else if ((fd = open(filename, O_RDONLY, WRMODE)) < 0) {
+       bu_log("pix_save: Cannot open file for saving\n");
+       return -1;
+    }
+    
     data =  data2uchar(bif);
     size = (size_t) bif->width*bif->height*3;
-    fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, WRMODE);
     ret = write(fd, data, size);
     close(fd);
     if (ret != size) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to