Revision: 56413
http://sourceforge.net/p/brlcad/code/56413
Author: mohitdaga
Date: 2013-08-01 13:40:58 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
Segrgating routines related to pix format
Modified Paths:
--------------
brlcad/trunk/src/libicv/CMakeLists.txt
brlcad/trunk/src/libicv/fileformat.c
Added Paths:
-----------
brlcad/trunk/src/libicv/pix.c
Modified: brlcad/trunk/src/libicv/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libicv/CMakeLists.txt 2013-08-01 13:09:58 UTC (rev
56412)
+++ brlcad/trunk/src/libicv/CMakeLists.txt 2013-08-01 13:40:58 UTC (rev
56413)
@@ -13,7 +13,8 @@
color_space.c
crop.c
filter.c
- bw.c
+ pix.c
+ bw.c
)
BRLCAD_ADDLIB(libicv "${LIBICV_SOURCES}" "libbu;libbn;${PNG_LIBRARY}")
Modified: brlcad/trunk/src/libicv/fileformat.c
===================================================================
--- brlcad/trunk/src/libicv/fileformat.c 2013-08-01 13:09:58 UTC (rev
56412)
+++ brlcad/trunk/src/libicv/fileformat.c 2013-08-01 13:40:58 UTC (rev
56413)
@@ -50,11 +50,15 @@
#define WRMODE S_IRUSR|S_IRGRP|S_IROTH
/* defined in bw.c */
-extern double *uchar2double(unsigned char *data, long int size);
-extern unsigned char *data2uchar(const icv_image_t *bif);
-extern int bw_save(icv_image_t *bif, const char *filename);
-extern icv_image_t *bw_load(const char *filename, int width, int height);
+extern HIDDEN double *uchar2double(unsigned char *data, long int size);
+extern HIDDEN unsigned char *data2uchar(const icv_image_t *bif);
+extern HIDDEN int bw_save(icv_image_t *bif, const char *filename);
+extern HIDDEN icv_image_t *bw_load(const char *filename, int width, int
height);
+/* defined in pix.c */
+extern HIDDEN int pix_save(icv_image_t *bif, const char *filename);
+extern HIDDEN icv_image_t *pix_load(const char* filename, int width, int
height);
+
/* private functions */
/* flip an image vertically */
@@ -159,33 +163,7 @@
return 1;
}
-
HIDDEN int
-pix_save(icv_image_t *bif, const char *filename)
-{
- unsigned char *data;
- int fd;
- size_t ret, size;
-
- if (bif->color_space == ICV_COLOR_SPACE_GRAY) {
- icv_gray2rgb(bif);
- } else if (bif->color_space != ICV_COLOR_SPACE_RGB) {
- bu_log("pix_save : Color Space conflict");
- 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) {
- bu_log("pix_save : Short Write");
- return -1;
- }
- return 0;
-}
-
-HIDDEN int
ppm_save(icv_image_t *bif, const char *filename)
{
unsigned char *data;
@@ -216,47 +194,6 @@
return 0;
}
-
-HIDDEN icv_image_t *
-pix_load(const char* filename, int width, int height)
-{
- int fd;
- unsigned char *data = 0;
- icv_image_t *bif;
-
- size_t size;
-
- if (width == 0 || height == 0) {
- height = 512;
- width = 512;
- }
-
- size = (size_t) height*width*3;
-
- if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
- bu_log("pix_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) {
- bu_log("pix_load: Error Occurred while Reading\n");
- bu_free(data, "icv_image data");
- return NULL;
- }
- BU_ALLOC(bif, struct icv_image);
- ICV_IMAGE_INIT(bif);
- bif->data = uchar2double(data, size);
- bu_free(data, "pix_load : unsigned char data");
- bif->magic = ICV_IMAGE_MAGIC;
- bif->height = height;
- bif->width = width;
- bif->channels = 3;
- bif->color_space = ICV_COLOR_SPACE_RGB;
- close(fd);
- return bif;
-}
-
-
/* end of private functions */
/* begin public functions */
Added: brlcad/trunk/src/libicv/pix.c
===================================================================
--- brlcad/trunk/src/libicv/pix.c (rev 0)
+++ brlcad/trunk/src/libicv/pix.c 2013-08-01 13:40:58 UTC (rev 56413)
@@ -0,0 +1,117 @@
+/* P I X . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file pix.c
+ *
+ * Brief description
+ *
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <sys/stat.h> /* for file mode info in WRMODE */
+#include <fcntl.h>
+
+#include "bio.h"
+#include "bu.h"
+#include "bn.h"
+#include "icv.h"
+
+/* this might be a little better than saying 0444 */
+#define WRMODE S_IRUSR|S_IRGRP|S_IROTH
+
+/* defined in bw.c */
+extern HIDDEN double *uchar2double(unsigned char *data, long int size);
+extern HIDDEN unsigned char *data2uchar(const icv_image_t *bif);
+
+HIDDEN int
+pix_save(icv_image_t *bif, const char *filename)
+{
+ unsigned char *data;
+ int fd;
+ size_t ret, size;
+
+ if (bif->color_space == ICV_COLOR_SPACE_GRAY) {
+ icv_gray2rgb(bif);
+ } else if (bif->color_space != ICV_COLOR_SPACE_RGB) {
+ bu_log("pix_save : Color Space conflict");
+ 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) {
+ bu_log("pix_save : Short Write");
+ return -1;
+ }
+ return 0;
+}
+
+
+HIDDEN icv_image_t *
+pix_load(const char* filename, int width, int height)
+{
+ int fd;
+ unsigned char *data = 0;
+ icv_image_t *bif;
+
+ size_t size;
+
+ if (width == 0 || height == 0) {
+ height = 512;
+ width = 512;
+ }
+
+ size = (size_t) height*width*3;
+
+ if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
+ bu_log("pix_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) {
+ bu_log("pix_load: Error Occurred while Reading\n");
+ bu_free(data, "icv_image data");
+ return NULL;
+ }
+ BU_ALLOC(bif, struct icv_image);
+ ICV_IMAGE_INIT(bif);
+ bif->data = uchar2double(data, size);
+ bu_free(data, "pix_load : unsigned char data");
+ bif->magic = ICV_IMAGE_MAGIC;
+ bif->height = height;
+ bif->width = width;
+ bif->channels = 3;
+ bif->color_space = ICV_COLOR_SPACE_RGB;
+ close(fd);
+ return bif;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/libicv/pix.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits