[giv] Fixed display of one-bit tiff images. Bumped version to 0.9.24.



commit 1f956f1e3a29d413aa16ffd9a59001e3188a2d32
Author: Dov Grobgeld <dov grobgeld gmail com>
Date:   Sat Dec 29 20:41:57 2012 +0200

    Fixed display of one-bit tiff images. Bumped version to 0.9.24.

 configure.in         |    2 +-
 src/giv-win.gob      |    2 +-
 src/givimage.c       |    9 ++++++++-
 src/givimage.h       |   11 +++++++++++
 src/plugins/dicom.cc |    3 +--
 src/plugins/tiff.c   |    8 ++++++++
 6 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/configure.in b/configure.in
index d39f26b..12b3b8f 100644
--- a/configure.in
+++ b/configure.in
@@ -5,7 +5,7 @@ AM_CONFIG_HEADER(config.h)
 PACKAGE=givwidget
 GIVWIDGET_API_VERSION=2.0
 
-AM_INIT_AUTOMAKE(giv, 0.9.24beta2)
+AM_INIT_AUTOMAKE(giv, 0.9.24)
 
 dnl Use libtool to get shared libraries
 LT_PREREQ
diff --git a/src/giv-win.gob b/src/giv-win.gob
index 86832f0..837549a 100644
--- a/src/giv-win.gob
+++ b/src/giv-win.gob
@@ -1111,7 +1111,7 @@ class Giv:Win from Gtk:Window
 
         if (!new_img)
             ; // Ignore
-        else if (selfp->do_auto_contrast)
+        else if (selfp->do_auto_contrast || new_img->one_bit)
             giv_image_get_min_max(new_img,
                                   // output
                                   &selfp->contrast_min,
diff --git a/src/givimage.c b/src/givimage.c
index 87bfe54..6460a24 100644
--- a/src/givimage.c
+++ b/src/givimage.c
@@ -60,7 +60,9 @@ GivImage *giv_image_new_full(GivImageType img_type,
                                                g_str_equal,
                                                g_free,
                                                g_free);
-
+    // One bit is used for signalling one bit images. This should
+    // eventually be moved into image type. By default it is off.
+    img->one_bit = FALSE;
     return img;
 }
 
@@ -687,3 +689,8 @@ GdkPixbuf *giv_image_get_pixbuf(GivImage *img,
     }
     return pixbuf;
 }
+
+void giv_image_set_one_bit(GivImage *img,gboolean one_bit)
+{
+  img->one_bit = one_bit;
+}
diff --git a/src/givimage.h b/src/givimage.h
index fe051da..6d79aea 100644
--- a/src/givimage.h
+++ b/src/givimage.h
@@ -71,6 +71,7 @@ typedef struct {
     int depth;
     int row_stride;
     int frame_stride;
+    gboolean one_bit;
     union {
         guint8 *buf;
         guint16 *sbuf;
@@ -259,6 +260,16 @@ GdkPixbuf *giv_image_get_pixbuf(GivImage *img,
  */
 int giv_image_type_get_size(GivImageType img_type);
 
+/** 
+ * Set an indicator that this is a one bit image.
+ * 
+ * @param img
+ * @param one_bit - Whether the image is a one bit image
+ * 
+ * @return 
+ */
+void giv_image_set_one_bit(GivImage *img, gboolean one_bit);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/src/plugins/dicom.cc b/src/plugins/dicom.cc
index 74ab85e..755a271 100644
--- a/src/plugins/dicom.cc
+++ b/src/plugins/dicom.cc
@@ -1,6 +1,5 @@
 //======================================================================
-//  dicom.c - A simple dicom loader. Should be replaced with dcmtk
-//            based loader.
+//  dicom.c - A dicom loader based on dcmtk.
 //
 //  Dov Grobgeld <dov grobgeld gmail com>
 //  Mon Nov  9 06:28:09 2009
diff --git a/src/plugins/tiff.c b/src/plugins/tiff.c
index afd93bf..5cc19a4 100644
--- a/src/plugins/tiff.c
+++ b/src/plugins/tiff.c
@@ -63,6 +63,7 @@ GivImage *giv_plugin_load_file(const char *filename,
         uint16 pn=0, num_pages=0;
         uint16 photometric;
         gboolean do_invert = TRUE;
+        gboolean one_bit = FALSE;
 
 	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
 	TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
@@ -119,6 +120,7 @@ GivImage *giv_plugin_load_file(const char *filename,
                 image_type = GIVIMAGE_I32;
             else if (bps == 1) {
                 image_type = GIVIMAGE_U8;
+                one_bit = TRUE;
                 if (photometric == PHOTOMETRIC_MINISBLACK)
                   do_invert = FALSE;
             }
@@ -132,6 +134,8 @@ GivImage *giv_plugin_load_file(const char *filename,
                 *error = g_error_new(GIV_IMAGE_ERROR, -1, "Failed allocating memory for an image of size %dx%d pixels!", w, h);
                 return NULL;
             }
+            giv_image_set_one_bit(img, one_bit);
+
             guchar *dst = img->buf.buf;
             int dst_bpp = giv_image_type_get_size(image_type);
             int dst_row_stride = giv_image_get_row_stride(img);
@@ -176,6 +180,10 @@ GivImage *giv_plugin_load_file(const char *filename,
 	    _TIFFfree(raster);
 	}
 	TIFFClose(tif);
+
+        char buf[32];
+        sprintf(buf,"%d",photometric);
+        giv_image_set_attribute(img, "photometric", buf);
     }
 
     return img;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]