Revision: 56727
http://sourceforge.net/p/brlcad/code/56727
Author: mohitdaga
Date: 2013-08-09 21:25:37 +0000 (Fri, 09 Aug 2013)
Log Message:
-----------
Now icv_load can read images from stdin also.
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 19:38:05 UTC (rev 56726)
+++ brlcad/trunk/src/libicv/bw.c 2013-08-09 21:25:37 UTC (rev 56727)
@@ -80,9 +80,8 @@
int fd;
unsigned char *data = 0;
icv_image_t *bif;
+ ssize_t size;
- size_t size;
-
if (width == 0 || height == 0) {
height = 512;
width = 512;
@@ -90,12 +89,15 @@
size = (size_t) height*width;
- if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
+ if(filename==NULL)
+ fd = 0; /* for stdin */
+ else if ((fd = open(filename, O_RDONLY, WRMODE)) < 0) {
bu_log("bw_load: Cannot open file for reading\n");
return NULL;
- }
+ }
+
data = (unsigned char *)bu_malloc(size, "bw_load : unsigned char data");
- if (read(fd, data, size) !=0) {
+ if (read(fd, data, size) != size) {
bu_log("bw_load: Error Occurred while Reading\n");
bu_free(data, "icv_image data");
return NULL;
Modified: brlcad/trunk/src/libicv/pix.c
===================================================================
--- brlcad/trunk/src/libicv/pix.c 2013-08-09 19:38:05 UTC (rev 56726)
+++ brlcad/trunk/src/libicv/pix.c 2013-08-09 21:25:37 UTC (rev 56727)
@@ -74,7 +74,7 @@
unsigned char *data = 0;
icv_image_t *bif;
- size_t size;
+ ssize_t size;
if (width == 0 || height == 0) {
height = 512;
@@ -83,12 +83,15 @@
size = (size_t) height*width*3;
- if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
- bu_log("pix_load: Cannot open file for reading\n");
+ if(filename == NULL)
+ fd = 0; /* for stdin */
+ else if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
+ bu_log("bw_load: Cannot open file for reading\n");
return NULL;
- }
+ }
+
data = (unsigned char *)bu_malloc(size, "pix_load : unsigned char data");
- if (read(fd, data, size) !=0) {
+ if (read(fd, data, size) != size) {
bu_log("pix_load: Error Occurred while Reading\n");
bu_free(data, "icv_image data");
return NULL;
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