[Rawstudio-commit] r845 - in trunk: . src

Anders Brander anders at brander.dk
Thu Oct 12 01:23:45 CEST 2006


Author: abrander
Date: 2006-10-12 01:23:45 +0200 (Thu, 12 Oct 2006)
New Revision: 845

Added:
   trunk/src/rs-tiff.c
   trunk/src/rs-tiff.h
Modified:
   trunk/configure.in
   trunk/src/Makefile.am
   trunk/src/conf_interface.c
   trunk/src/gtk-interface.c
   trunk/src/rawstudio.c
   trunk/src/rawstudio.h
Log:
Added saver for 8 bit TIFF.

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/configure.in	2006-10-11 23:23:45 UTC (rev 845)
@@ -26,6 +26,22 @@
 fi
 AC_SUBST(LIBJPEG)
 
+dnl libtiff
+if test -z "$LIBTIFF"; then
+AC_CHECK_LIB(tiff, TIFFOpen, tiff_ok=yes, tiff_ok=no)
+  if test "$tiff_ok" = yes; then
+    AC_CHECK_HEADER(tiffio.h, tiff_ok=yes, tiff_ok=no)
+    if test "$tiff_ok" = yes; then
+      LIBTIFF='-ltiff'
+    else
+      AC_MSG_ERROR([*** libtiff header files not found.])
+    fi
+  else
+    AC_MSG_ERROR([*** Rawstudio requires libtiff.])
+  fi
+fi
+AC_SUBST(LIBTIFF)
+
 pkg_modules="gtk+-2.0 >= 2.0.0 libxml-2.0 >= 2.4 gconf-2.0 >= 2.0 lcms"
 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
 AC_SUBST(PACKAGE_CFLAGS)

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/Makefile.am	2006-10-11 23:23:45 UTC (rev 845)
@@ -30,6 +30,7 @@
 	rs-image.c rs-image.h \
 	dcraw_api.c dcraw_api.h \
 	rs-jpeg.c rs-jpeg.h \
+	rs-tiff.c rs-tiff.h \
 	color.h \
 	gettext.h \
 	rs-arch.h \
@@ -38,6 +39,6 @@
 	filename.c filename.h \
 	rs-render.c rs-render.h
 
-rawstudio_LDADD = @PACKAGE_LIBS@ @LIBJPEG@ dcraw_nomain.o $(INTLLIBS)
+rawstudio_LDADD = @PACKAGE_LIBS@ @LIBJPEG@ @LIBTIFF@ dcraw_nomain.o $(INTLLIBS)
 dcraw_nomain.o: dcraw.c 
 	$(COMPILE) -DDCRAW_NOMAIN -DNO_LCMS -o dcraw_nomain.o -c $(srcdir)/dcraw.c

Modified: trunk/src/conf_interface.c
===================================================================
--- trunk/src/conf_interface.c	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/conf_interface.c	2006-10-11 23:23:45 UTC (rev 845)
@@ -327,6 +327,8 @@
 			*filetype = FILETYPE_JPEG;
 		else if (0==g_ascii_strcasecmp(str, "png"))
 			*filetype = FILETYPE_PNG;
+		else if (0==g_ascii_strcasecmp(str, "tif"))
+			*filetype = FILETYPE_TIFF8;
 		g_free(str);
 		return(TRUE);
 	}

Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/gtk-interface.c	2006-10-11 23:23:45 UTC (rev 845)
@@ -69,6 +69,7 @@
 } savers[] = {
 	{"jpg", _("JPEG (Joint Photographic Experts Group)"), FILETYPE_JPEG},
 	{"png", _("PNG (Portable Network Graphics)"), FILETYPE_PNG},
+	{"tif", _("TIFF-8bit (Tagged Image File Format)"), FILETYPE_TIFF8},
 	{NULL, NULL, -1},
 };
 
@@ -1638,6 +1639,8 @@
 		g_string_append(save, "jpg");
 	else if (conf_export_filetype == FILETYPE_PNG)
 		g_string_append(save, "png");
+	else if (conf_export_filetype == FILETYPE_TIFF8)
+		g_string_append(save, "tif");
 	else
 		g_string_append(save, "jpg");
 

Modified: trunk/src/rawstudio.c
===================================================================
--- trunk/src/rawstudio.c	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/rawstudio.c	2006-10-11 23:23:45 UTC (rev 845)
@@ -37,6 +37,7 @@
 #include "conf_interface.h"
 #include "filename.h"
 #include "rs-jpeg.h"
+#include "rs-tiff.h"
 #include "rs-render.h"
 #include "rs-arch.h"
 
@@ -627,6 +628,15 @@
 			gdk_pixbuf_save(pixbuf, filename, "png", NULL, NULL);
 			g_object_unref(pixbuf);
 			break;
+		case FILETYPE_TIFF8:
+			image8 = rs_image8_new(rsi->w, rsi->h, 3, 3);
+			rs_render(photo, rsi->w, rsi->h, rsi->pixels,
+				rsi->rowstride, rsi->channels,
+				image8->pixels, image8->rowstride,
+				exportTransform);
+			rs_tiff8_save(image8, filename, profile_filename);
+			rs_image8_free(image8);
+			break;
 	}
 	if (photo->orientation)
 		rs_image16_free(rsi);

Modified: trunk/src/rawstudio.h
===================================================================
--- trunk/src/rawstudio.h	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/rawstudio.h	2006-10-11 23:23:45 UTC (rev 845)
@@ -210,6 +210,7 @@
 enum {
 	FILETYPE_JPEG,
 	FILETYPE_PNG,
+	FILETYPE_TIFF8,
 };
 
 typedef struct {

Added: trunk/src/rs-tiff.c
===================================================================
--- trunk/src/rs-tiff.c	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/rs-tiff.c	2006-10-11 23:23:45 UTC (rev 845)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2006 Anders Brander <anders at brander.dk> and 
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <tiffio.h>
+#include "matrix.h"
+#include "rs-batch.h"
+#include "rawstudio.h"
+
+gboolean
+rs_tiff8_save(RS_IMAGE8 *image, const gchar *filename, const gchar *profile_filename)
+{
+	TIFF *output;
+	gint row;
+
+	if((output = TIFFOpen(filename, "w")) == NULL)
+		return(FALSE);
+	TIFFSetField(output, TIFFTAG_IMAGEWIDTH, image->w);
+	TIFFSetField(output, TIFFTAG_IMAGELENGTH, image->h);
+	TIFFSetField(output, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+	TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, 3);
+	TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8);
+	TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+	TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+	TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
+	if (profile_filename)
+	{
+		struct stat st;
+		guchar *buffer;
+		gint fd;
+		stat(profile_filename, &st);
+		if (st.st_size>0)
+			if ((fd = open(profile_filename, O_RDONLY)) != -1)
+			{
+				buffer = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+				if (buffer)
+				{
+					TIFFSetField(output, TIFFTAG_ICCPROFILE, st.st_size, buffer);
+					g_free(buffer);
+					munmap(buffer, st.st_size);
+				}
+				close(fd);
+			}
+	}
+	TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(output, 0));
+	for(row=0;row<image->h;row++)
+	{
+		guchar *buf = image->pixels + image->rowstride * row;
+		TIFFWriteScanline(output, buf, row, 0);
+	}
+	TIFFClose(output);
+	return(TRUE);
+}

Added: trunk/src/rs-tiff.h
===================================================================
--- trunk/src/rs-tiff.h	2006-10-10 13:40:29 UTC (rev 844)
+++ trunk/src/rs-tiff.h	2006-10-11 23:23:45 UTC (rev 845)
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2006 Anders Brander <anders at brander.dk> and 
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+gboolean rs_tiff8_save(RS_IMAGE8 *image, const gchar *filename, const gchar *profile_filename);




More information about the Rawstudio-commit mailing list