diff -r 7a6553f9e3c7 -r f0242547f3b5 ChangeLog
--- a/ChangeLog	Wed Sep 27 07:17:49 2006 +0000
+++ b/ChangeLog	Wed Sep 27 07:27:37 2006 +0000
@@ -6,6 +6,10 @@ Tue Sep 26 18:15:00 2006  Uwe Ohse <uwe@
 	* Makefile.in, aclocal.m4, configure, doc/Makefile.in, 
 	  src/Makefile.in, src/icons/Makefile.in: aclocal, autoreconf, 
 	  automake.
+
+	* src/Makefile.am, src/Makefile.in, src/exif.c, src/filelist.c, 
+	  src/format_raw.c, src/format_pentax.c, src/format_pentax.h:
+	  add support for pentax .pef raw files.
 
 Mon Jun 13 20:22:58 2005  John Ellis  <johne@verizon.net>
 
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/Makefile.am
--- a/src/Makefile.am	Wed Sep 27 07:17:49 2006 +0000
+++ b/src/Makefile.am	Wed Sep 27 07:27:37 2006 +0000
@@ -92,6 +92,8 @@ gqview_SOURCES = \
 	format_nikon.h	\
 	format_olympus.c	\
 	format_olympus.h	\
+	format_pentax.c	\
+	format_pentax.h	\
 	format_raw.c	\
 	format_raw.h	\
 	fullscreen.c	\
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/Makefile.in
--- a/src/Makefile.in	Wed Sep 27 07:17:49 2006 +0000
+++ b/src/Makefile.in	Wed Sep 27 07:27:37 2006 +0000
@@ -61,8 +61,9 @@ am_gqview_OBJECTS = $(am__objects_1) bar
 	editors.$(OBJEXT) exif.$(OBJEXT) filelist.$(OBJEXT) \
 	format_canon.$(OBJEXT) format_fuji.$(OBJEXT) \
 	format_nikon.$(OBJEXT) format_olympus.$(OBJEXT) \
-	format_raw.$(OBJEXT) fullscreen.$(OBJEXT) globals.$(OBJEXT) \
-	image.$(OBJEXT) image-load.$(OBJEXT) image-overlay.$(OBJEXT) \
+	format_pentax.$(OBJEXT) format_raw.$(OBJEXT) \
+	fullscreen.$(OBJEXT) globals.$(OBJEXT) image.$(OBJEXT) \
+	image-load.$(OBJEXT) image-overlay.$(OBJEXT) \
 	img-view.$(OBJEXT) info.$(OBJEXT) layout.$(OBJEXT) \
 	layout_config.$(OBJEXT) layout_image.$(OBJEXT) \
 	layout_util.$(OBJEXT) main.$(OBJEXT) md5-util.$(OBJEXT) \
@@ -272,6 +273,8 @@ gqview_SOURCES = \
 	format_nikon.h	\
 	format_olympus.c	\
 	format_olympus.h	\
+	format_pentax.c	\
+	format_pentax.h	\
 	format_raw.c	\
 	format_raw.h	\
 	fullscreen.c	\
@@ -427,6 +430,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_fuji.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_nikon.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_olympus.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_pentax.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_raw.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fullscreen.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Po@am__quote@
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/exif.c
--- a/src/exif.c	Wed Sep 27 07:17:49 2006 +0000
+++ b/src/exif.c	Wed Sep 27 07:27:37 2006 +0000
@@ -106,6 +106,36 @@ ExifFormatAttrib ExifFormatList[] = {
  * Data
  *-----------------------------------------------------------------------------
  */
+static ExifTextList ExifCompressionList[] = {
+	{ 1, "Uncompressed" },
+	{ 2, "CCITT 1D" },
+	{ 3, "T4/Group 3 Fax" },
+	{ 4, "T6/Group 4 Fax" },
+	{ 5, "LZW" },
+	{ 6, "JPEG (old style)" },
+	{ 7, "JPEG" },
+	{ 8, "Adobe Deflate" },
+	{ 9, "JBIG B&W" },
+	{ 10, "JBIG Color" },
+	{ 32766, "Next" },
+	{ 32771, "CCIRLEW" },
+	{ 32773, "PackBits" },
+	{ 32809, "ThunderScan" },
+	{ 32895, "IT8CTPAD" },
+	{ 32896, "IT8LW" },
+	{ 32897, "IT8MP" },
+	{ 32898, "IT8BL" },
+	{ 32908, "PixasFilm" },
+	{ 32909, "PixasLog" },
+	{ 32946, "Deflate" },
+	{ 32947, "DCS" },
+	{ 34661, "JBIG" },
+	{ 34676, "SGILog" },
+	{ 34677, "SGILog24" },
+	{ 34712, "JPEF 2000" },
+	{ 34713, "Nikon NEF Compressed" },
+	EXIF_TEXT_LIST_END
+};
 
 static ExifTextList ExifOrientationList[] = {
 	{ EXIF_ORIENTATION_UNKNOWN,	N_("unknown") },
@@ -284,7 +314,13 @@ static ExifTextList ExifSubjectRangeList
 	EXIF_TEXT_LIST_END
 };
 
+
+
 ExifMarker ExifKnownMarkersList[] = {
+{ 0x0100, EXIF_FORMAT_LONG_UNSIGNED, 1,		"ImageWidth",	N_("Image Width"), NULL },
+{ 0x0101, EXIF_FORMAT_LONG_UNSIGNED, 1,		"ImageHeight",	N_("Image Height"), NULL },
+{ 0x0102, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"BitsPerSample",	N_("Bits per Sample/Pixel"), NULL },
+{ 0x0103, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Compression",	N_("Compression"), ExifCompressionList },
 { 0x010e, EXIF_FORMAT_STRING, -1,		"ImageDescription",	N_("Image description"), NULL },
 { 0x010f, EXIF_FORMAT_STRING, -1,		"Make",			"Camera make", NULL },
 { 0x0110, EXIF_FORMAT_STRING, -1,		"Model",		"Camera model", NULL },
@@ -755,7 +791,6 @@ static gint exif_parse_IFD_entry(ExifDat
 	guint data_length;
 	const ExifMarker *marker;
 	ExifItem *item;
-
 	tag = exif_byte_get_int16(tiff + offset + EXIF_TIFD_OFFSET_TAG, bo);
 	format = exif_byte_get_int16(tiff + offset + EXIF_TIFD_OFFSET_FORMAT, bo);
 	count = exif_byte_get_int32(tiff + offset + EXIF_TIFD_OFFSET_COUNT, bo);
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/filelist.c
--- a/src/filelist.c	Wed Sep 27 07:17:49 2006 +0000
+++ b/src/filelist.c	Wed Sep 27 07:27:37 2006 +0000
@@ -214,6 +214,7 @@ void filter_add_defaults(void)
 	filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", TRUE);
 	filter_add_if_missing("raf", "Fujifilm raw format", ".raf", TRUE);
 	filter_add_if_missing("nef", "Nikon raw format", ".nef", TRUE);
+	filter_add_if_missing("pef", "Pentax raw format", ".pef", TRUE);
 }
 
 static GList *filter_to_list(const gchar *extensions)
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/format_raw.c
--- a/src/format_raw.c	Wed Sep 27 07:17:49 2006 +0000
+++ b/src/format_raw.c	Wed Sep 27 07:27:37 2006 +0000
@@ -32,6 +32,7 @@
 #include "format_fuji.h"
 #include "format_nikon.h"
 #include "format_olympus.h"
+#include "format_pentax.h"
 
 
 /* so that debugging is honored */
@@ -53,6 +54,7 @@ static FormatRawEntry format_raw_list[] 
 	FORMAT_RAW_CANON,
 	FORMAT_RAW_FUJI,
 	FORMAT_RAW_NIKON,
+	FORMAT_RAW_PENTAX,
 	{ NULL, 0, 0, NULL, 0, NULL, NULL }
 };
 
@@ -71,6 +73,7 @@ static FormatExifEntry format_exif_list[
 	FORMAT_EXIF_FUJI,
 	FORMAT_EXIF_NIKON,
 	FORMAT_EXIF_OLYMPUS,
+	FORMAT_EXIF_PENTAX,
 	{ 0, NULL, 0, NULL }
 };
 
@@ -187,7 +190,6 @@ static FormatRawEntry *format_raw_find(u
 	while (format_raw_list[n].magic_pattern)
 		{
 		FormatRawEntry *entry = &format_raw_list[n];
-
 		switch (entry->magic_type)
 			{
 			case FORMAT_RAW_MATCH_MAGIC:
@@ -389,7 +391,6 @@ gint format_exif_makernote_parse(ExifDat
 				 guint size, ExifByteOrder bo)
 {
 	FormatExifEntry *entry;
-
 	entry = format_exif_makernote_find(exif, tiff, offset, size);
 
 	if (!entry || !entry->func_parse) return FALSE;
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/format_pentax.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/format_pentax.c	Wed Sep 27 07:27:37 2006 +0000
@@ -0,0 +1,532 @@
+/*
+ *  GQView
+ *  (C) 2005 John Ellis
+ *
+ *  Authors:
+ *    Raw NEF jpeg extraction based on nefextract.c by Joseph Heled,
+ *        in addition nefextract.c is based on dcraw by Dave Coffin.
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <glib.h>
+
+#include "intl.h"
+
+#include "format_pentax.h"
+
+#include "exif.h"
+
+
+/*
+ *-----------------------------------------------------------------------------
+ * Raw NEF embedded jpeg extraction for Nikon
+ *-----------------------------------------------------------------------------
+ */
+
+static guint pentax_tiff_table(unsigned char *data, const guint len, guint offset, ExifByteOrder bo,
+			      gint level,
+			      guint *image_offset, guint *jpeg_len);
+
+
+static void pentax_tiff_entry(unsigned char *data, const guint len, guint offset, ExifByteOrder bo,
+			     gint level,
+			     guint *image_offset, guint *image_length, guint *jpeg_start, guint *jpeg_len)
+{
+	guint tag;
+	guint type;
+	guint count;
+	guint segment;
+	guint seg_len;
+
+	tag = exif_byte_get_int16(data + offset + EXIF_TIFD_OFFSET_TAG, bo);
+	type = exif_byte_get_int16(data + offset + EXIF_TIFD_OFFSET_FORMAT, bo);
+	count = exif_byte_get_int32(data + offset + EXIF_TIFD_OFFSET_COUNT, bo);
+
+	/* so far, we only care about tags with type long */
+	if (type != EXIF_FORMAT_LONG_UNSIGNED && type != EXIF_FORMAT_LONG) return;
+
+	seg_len = ExifFormatList[type].size * count;
+	if (seg_len > 4)
+		{
+		segment = exif_byte_get_int32(data + offset + EXIF_TIFD_OFFSET_DATA, bo);
+		if (segment + seg_len > len) return;
+		}
+	else
+		{
+		segment = offset + EXIF_TIFD_OFFSET_DATA;
+		}
+
+	if (tag == 0x14a)
+		{
+		/* sub IFD table */
+		gint i;
+
+		for (i = 0; i < count; i++)
+			{
+			guint subset;
+
+			subset = exif_byte_get_int32(data + segment + i * 4, bo);
+			pentax_tiff_table(data, len, subset, bo, level + 1, image_offset, image_length);
+			}
+
+		}
+	else if (tag == 0x201)
+		{
+		/* jpeg data start offset */
+		*jpeg_start = exif_byte_get_int32(data + segment, bo);
+		}
+	else if (tag == 0x202)
+		{
+		/* jpeg data length */
+		*jpeg_len = exif_byte_get_int32(data + segment, bo);
+		}
+}
+
+static guint pentax_tiff_table(unsigned char *data, const guint len, guint offset, ExifByteOrder bo,
+			      gint level,
+			      guint *image_offset, guint *image_length)
+{
+	guint count;
+	guint i;
+	guint jpeg_start = 0;
+	guint jpeg_len = 0;
+
+	/* limit damage from infinite loops */
+	if (level > EXIF_TIFF_MAX_LEVELS) return 0;
+
+	if (len < offset + 2) return FALSE;
+
+	count = exif_byte_get_int16(data + offset, bo);
+	offset += 2;
+	if (len < offset + count * EXIF_TIFD_SIZE + 4) return 0;
+
+	for (i = 0; i < count; i++)
+		{
+		pentax_tiff_entry(data, len, offset + i * EXIF_TIFD_SIZE, bo, level,
+				 image_offset, image_length, &jpeg_start, &jpeg_len);
+		}
+
+	if (jpeg_start > 0 &&
+	    jpeg_len > *image_length)
+		{
+		*image_offset = jpeg_start;
+		*image_length = jpeg_len;
+		}
+
+	return exif_byte_get_int32(data + offset + count * EXIF_TIFD_SIZE, bo);
+}
+
+gint format_pentax_raw(unsigned char *data, const guint len,
+		      guint *image_offset, guint *exif_offset)
+{
+	guint i_off = 0;
+	guint i_len = 0;
+	ExifByteOrder bo;
+	guint offset;
+	gint level;
+	if (!exif_tiff_directory_offset(data, len, &offset, &bo)) return FALSE;
+
+	level = 0;
+	while (offset && level < EXIF_TIFF_MAX_LEVELS)
+		{
+		offset = pentax_tiff_table(data, len, offset, bo, 0, &i_off, &i_len);
+		level++;
+		}
+
+	if (i_off != 0)
+		{
+		if (image_offset) *image_offset = i_off;
+		return TRUE;
+		}
+
+	return FALSE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ * EXIF Makernote for Pentax
+ *-----------------------------------------------------------------------------
+ */
+
+
+
+static ExifTextList NikonTagQuality[]= {
+	{ 1,	"VGA basic" },
+	{ 2,	"VGA normal" },
+	{ 3,	"VGA fine" },
+	{ 4,	"SXGA basic" },
+	{ 5,	"SXGA normal" },
+	{ 6,	"SXGA fine" },
+	{ 7,	"XGA basic (?)" },
+	{ 8,	"XGA normal (?)" },
+	{ 9,	"XGA fine (?)" },
+	{ 10,	"UXGA basic" },
+	{ 11,	"UXGA normal" },
+	{ 12,	"UXGA fine" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTagColorMode[]= {
+	{ 1,	"color" },
+	{ 2,	"monochrome" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTagImgAdjust[]= {
+	{ 0,	"normal" },
+	{ 1,	"bright+" },
+	{ 2,	"bright-" },
+	{ 3,	"contrast+" },
+	{ 4,	"contrast-" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTagISOSensitivity[]= {
+	{ 0,	"80" },
+	{ 2,	"160" },
+	{ 4,	"320" },
+	{ 5,	"100" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTagWhiteBalance[]= {
+	{ 0,	"auto" },
+	{ 1,	"preset" },
+	{ 2,	"daylight" },
+	{ 3,	"incandescent" },
+	{ 4,	"fluorescence" },
+	{ 5,	"cloudy" },
+	{ 6,	"speedlight" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTagConverter[]= {
+	{ 0,	"none" },
+	{ 1,	"Fisheye" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagCaptureMode[]= {
+	{ 0,	"Auto" },
+	{ 1,	"Night Scene" },
+	{ 2,	"Manual" },
+	{ 2,	"Multiple" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagISOSpeed[]= {
+	{ 3,	"50" },
+	{ 4,	"64" },
+	{ 5,	"80" },
+	{ 6,	"100" },
+	{ 7,	"125" },
+	{ 8,	"160" },
+	{ 9,	"200" },
+	{10,	"250" },
+	{11,	"320" },
+	{12,	"400" },
+	{13,	"500" },
+	{14,	"640" },
+	{15,	"800" },
+	{16,	"1000" },
+	{17,	"1250" },
+	{18,	"1600" },
+	{21,	"3200" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagPictureMode[]= {
+	{ 0,	"Programm" },
+	{ 5,	"Portrait" },
+	{ 6,	"Landscape" },
+	{ 8,	"Sport" },
+	{ 9,	"Night Scene" },
+	{11,	"Soft" },
+	{12,	"Surf & Snow" },
+	{13,	"Sunset" },
+	{14,	"Autumn" },
+	{15,	"Flower" },
+	{17,	"Fireworks" },
+	{18,	"Text" },
+	{19,	"Panorama" },
+	{30,	"Self Portrait" },
+	{37,	"Museum" },
+	{38,	"Food" },
+	{40,	"Green Mode" },
+	{49,	"Light Pet" },
+	{50,	"Dark Pet" },
+	{51,	"Medium Pet" },
+	{53,	"Underwater" },
+	{54,	"Candlelight" },
+	{55,	"Natural Skin Tone" },
+	{56,	"Synchro Sound Record" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagWhiteBalance[]= {
+	{ 0,	"Auto" },
+	{ 1,	"Daylight" },
+	{ 2,	"Shade" },
+	{ 3,	"Fluorescent" },
+	{ 4,	"Tungsten" },
+	{ 5,	"Manual" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagWhiteBalanceMode[]= {
+	{ 1,	"Auto (Daylight?)" },
+	{ 2,	"Auto (Shade?)" },
+	{ 3,	"Auto (Flash?)" },
+	{ 4,	"Auto (Tungsten?)" },
+	{ 65534,"Preset (Fireworks?)" },
+	{ 65535,"User-Selected" },
+	EXIF_TEXT_LIST_END
+};
+static ExifTextList PentaxTagMeteringMode[]= {
+	{ 0,	"MultiSegment" },
+	{ 1,	"CenterWeighted" },
+	{ 2,	"Spot" },
+	EXIF_TEXT_LIST_END
+};
+
+#if 0
+static ExifTextList NikonTag[]= {
+	{ ,	"" },
+	{ ,	"" },
+	EXIF_TEXT_LIST_END
+};
+#endif
+
+static ExifMarker PentaxExifMarkersList1[] = {
+{ 0x0001, EXIF_FORMAT_SHORT_UNSIGNED, 1,
+		"Pentax.CaptureMode",	"Capture mode",	 PentaxTagCaptureMode},
+{ 0x0006, EXIF_FORMAT_UNDEFINED, 4,	"Pentax.Date",	"Date",	 NULL },
+{ 0x0007, EXIF_FORMAT_UNDEFINED, 3,	"Pentax.Time",	"Time",	 NULL },
+
+{ 0x000b, EXIF_FORMAT_SHORT_UNSIGNED, 1,	
+		"Pentax. PictureMode",	"Picture mode",	 PentaxTagPictureMode},
+{ 0x0012, EXIF_FORMAT_LONG_UNSIGNED, 1,	"Pentax.ExposureTime",       "ExposureTime",	NULL },
+{ 0x0013, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Pentax.FNumber",       "FNumber",	NULL },
+{ 0x0014, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Pentax.ISOSpeed",
+								"ISO Speed",	PentaxTagISOSpeed },
+{ 0x0016, EXIF_FORMAT_SHORT_UNSIGNED, 1,
+	"Pentax.ExposureCompensation", "Exposure Compensation",	NULL },
+{ 0x0017, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Pentax.MeteringMode",
+								"Metering Mode",PentaxTagMeteringMode },
+{ 0x0019, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Pentax.WhileBalance",
+								"White Balance",PentaxTagWhiteBalance },
+{ 0x001a, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Pentax.WhileBalanceMode",
+						"White Balance Mode",PentaxTagWhiteBalanceMode },
+EXIF_MARKER_LIST_END
+};
+
+static ExifTextList NikonTag2FlashComp[]= {
+	{ 0x06,	"+1.0 EV" },
+	{ 0x04,	"+0.7 EV" },
+	{ 0x03,	"+0.5 EV" },
+	{ 0x02,	"+0.3 EV" },
+	{ 0x00,	"0.0 EV" },
+	{ 0xfe,	"-0.3 EV" },
+	{ 0xfd,	"-0.5 EV" },
+	{ 0xfc,	"-0.7 EV" },
+	{ 0xfa,	"-1.0 EV" },
+	{ 0xf8,	"-1.3 EV" },
+	{ 0xf7,	"-1.5 EV" },
+	{ 0xf6,	"-1.7 EV" },
+	{ 0xf4,	"-2.0 EV" },
+	{ 0xf2,	"-2.3 EV" },
+	{ 0xf1,	"-2.5 EV" },
+	{ 0xf0,	"-2.7 EV" },
+	{ 0xee,	"-3.0 EV" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTag2LensType[]= {
+	{ 0,	"AF non D" },
+	{ 1,	"manual" },
+	{ 2,	"AF-D or AF-s" },
+	{ 6,	"AF-D G" },
+	{ 10,	"AF-D VR" },
+	EXIF_TEXT_LIST_END
+};
+
+static ExifTextList NikonTag2FlashUsed[]= {
+	{ 0,	"no" },
+	{ 4,	"unit unknown" },
+	{ 7,	"external" },
+	{ 9,	"yes" },
+	EXIF_TEXT_LIST_END
+};
+
+#if 0
+static ExifTextList NikonTagi2Saturation[]= {
+	{ -3,	"black and white" },
+	{ -2,	"-2" },
+	{ -1,	"-1" },
+	{ 0,	"normal" },
+	{ 1,	"+1" },
+	{ 2,	"+2" },
+	EXIF_TEXT_LIST_END
+};
+#endif
+
+static ExifMarker NikonExifMarkersList2[] = {
+{ 0x0002, EXIF_FORMAT_SHORT_UNSIGNED, 2,	"Nikon.ISOSpeed",	"ISO speed",	NULL },
+{ 0x0003, EXIF_FORMAT_STRING, -1,		"Nikon.ColorMode",	"Color mode",	NULL },
+{ 0x0004, EXIF_FORMAT_STRING, -1,		"Nikon.Quality",	"Quality",	NULL },
+{ 0x0005, EXIF_FORMAT_STRING, -1,		"Nikon.WhiteBalance",	"White balance",NULL },
+{ 0x0006, EXIF_FORMAT_STRING, -1,		"Nikon.Sharpening",	"Sharpening",	NULL },
+{ 0x0007, EXIF_FORMAT_STRING, -1,		"Nikon.FocusMode",	"Focus mode",	NULL },
+{ 0x0008, EXIF_FORMAT_STRING, -1,		"Nikon.FlashSetting",	"Flash setting",NULL },
+{ 0x0009, EXIF_FORMAT_STRING, -1,		"Nikon.AutoFlashMode","Auto flash mode",NULL },
+{ 0x000b, EXIF_FORMAT_SHORT, 1,			"Nikon.WhiteBalanceBias",
+							"White balance bias value",	NULL },
+/* { 0x000c, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Nikon.WhiteBalanceRB",
+						"White balance red/blue coefficients",	NULL }, */
+/* { 0x000f, EXIF_FORMAT_STRING, -1,		"Nikon.ISOSelect",	"ISO selection",NULL }, */
+{ 0x0012, EXIF_FORMAT_UNDEFINED, 4,		"Nikon.FlashCompensation",
+								"Flash compensation",	NikonTag2FlashComp },
+{ 0x0013, EXIF_FORMAT_SHORT_UNSIGNED, 2,	"Nikon.ISOSpeedRequest",
+								"ISO speed requested",	NULL },
+{ 0x0016, EXIF_FORMAT_SHORT_UNSIGNED, 4,	"Nikon.CornerCoord",
+								"Corner coordinates",	NULL },
+{ 0x0018, EXIF_FORMAT_UNDEFINED, 4,		"Nikon.FlashBracketCompensation",
+							"Flash bracket compensation",	NikonTag2FlashComp },
+{ 0x0019, EXIF_FORMAT_RATIONAL, 1,		"Nikon.AEBracketCompensation",
+							"AE bracket compensation",	NULL },
+{ 0x0080, EXIF_FORMAT_STRING, -1,		"Nikon.ImageAdjustment",
+								"Image adjustment",	NULL },
+{ 0x0081, EXIF_FORMAT_STRING, -1,		"Nikon.Contrast",	"Contrast",	NULL },
+{ 0x0082, EXIF_FORMAT_STRING, -1,		"Nikon.AuxLens", "Aux lens adapter",	NULL },
+{ 0x0083, EXIF_FORMAT_BYTE_UNSIGNED, -1,	"Nikon.LensType",	"Lens type",	NikonTag2LensType },
+{ 0x0084, EXIF_FORMAT_RATIONAL_UNSIGNED, -1,	"Nikon.LensFocalLength",
+							"Lens min/max focal length and aperture", NULL },
+{ 0x0085, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Nikon.ManualFocusDistance",
+							"Manual focus distance", 	NULL },
+{ 0x0086, EXIF_FORMAT_RATIONAL, 1,		"Nikon.DigitalZoomFactor",
+							"Digital zoom factor",		NULL },
+{ 0x0087, EXIF_FORMAT_BYTE_UNSIGNED, 1,		"Nikon.FlashUsed",	"Flash used",	NikonTag2FlashUsed },
+{ 0x0088, EXIF_FORMAT_UNDEFINED, 4,		"Nikon.AutoFocusArea","Auto focus area",NULL },
+/* { 0x0089, EXIF_FORMAT_SHORT_UNSIGNED, -1,	"Nikon.Bracket/ShootingMode", NULL,	NULL }, */
+{ 0x008d, EXIF_FORMAT_STRING, -1,		"Nikon.ColorMode",	"Color mode",	NULL },
+{ 0x008f, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Nikon.SceneMode",	"Scene mode",	NULL },
+{ 0x0090, EXIF_FORMAT_STRING, -1,		"Nikon.LightingType",	"Lighting type",NULL },
+{ 0x0092, EXIF_FORMAT_SHORT, 1,			"Nikon.HueAdjust",	"Hue adjustment",NULL },
+/* { 0x0094, EXIF_FORMAT_SHORT_UNSIGNED, 1,	"Nikon.Saturation",	"Saturation",	NikonTag2Saturation }, */
+{ 0x0095, EXIF_FORMAT_STRING, -1,		"Nikon.NoiseReduction", "Noise reduction", NULL },
+{ 0x00a7, EXIF_FORMAT_LONG_UNSIGNED, 1,		"Nikon.ShutterCount", "Shutter release count", NULL },
+{ 0x00a9, EXIF_FORMAT_STRING, -1,		"Nikon.ImageOptimization", "Image optimization", NULL },
+{ 0x00aa, EXIF_FORMAT_STRING, -1,		"Nikon.Saturation", "Saturation",	NULL },
+{ 0x00ab, EXIF_FORMAT_STRING, -1,		"Nikon.DigitalVariProg", "Digital Vari-program", NULL },
+EXIF_MARKER_LIST_END
+};
+
+static ExifTextList NikonAFPoint[]= {
+	{ 0,	"center" },
+	{ 1,	"top" },
+	{ 2,	"bottom" },
+	{ 3,	"left" },
+	{ 4,	"right" },
+	EXIF_TEXT_LIST_END
+};
+
+
+gint format_pentax_makernote(ExifData *exif, unsigned char *tiff, guint offset,
+			    guint size, ExifByteOrder bo)
+{
+	unsigned char *data;
+	ExifItem *item;
+	if (offset + 8 + 4 >= size) return FALSE;
+
+	data = tiff + offset;
+
+	/* Pentax tag format 2 */
+	if (memcmp(data, "AOC\0", 4) == 0)
+		{
+		if (exif_parse_IFD_table(exif, tiff, offset + 6, size,
+					 bo, 0, PentaxExifMarkersList1) != 0)
+			{
+			return FALSE;
+			}
+		return TRUE;
+		}
+	else
+		return FALSE;
+#if 0
+	/* Nikon tag format 2 uses Embedded tiff header */
+	if (memcmp(data, "Nikon\x00\x02\x00\x00\x00", 10) == 0 ||
+	    memcmp(data, "Nikon\x00\x02\x10\x00\x00", 10) == 0)
+		{
+		guint tiff_header;
+
+		tiff_header = offset + 10;
+		if (exif_tiff_parse(exif, tiff + tiff_header, size - tiff_header,
+		    NikonExifMarkersList2) != 0)
+			{
+			return FALSE;
+			}
+		}
+	/* Nikon tag format 3 uses format 2 tags without "Nikon" and tiff header */
+	else if (exif_parse_IFD_table(exif, tiff, offset, size,
+				      bo, 0, NikonExifMarkersList2) != 0)
+		{
+		return FALSE;
+		}
+#endif
+	item = exif_get_item(exif, "Nikon.AutoFocusArea");
+	if (item && item->data_len == 4 * sizeof(guchar))
+		{
+		static ExifMarker marker = { 0x0088, EXIF_FORMAT_STRING, -1,
+					     "Nikon.AutoFocusPoint", "Auto focus point", NULL };
+		guchar *array = item->data;
+		gchar *text;
+		gint l;
+
+		text = exif_text_list_find_value(NikonAFPoint, (gint)array[1]);
+		l = strlen(text) + 1;
+
+		item = exif_item_new(marker.format, marker.tag, l, &marker);
+		memcpy(item->data, text, l);
+
+		g_free(text);
+
+		exif->items = g_list_prepend(exif->items, item);
+		}
+
+	item = exif_get_item(exif, "Nikon.ISOSpeed");
+	if (item && item->data_len == 2 * 2)
+		{
+		static ExifMarker marker = { 0x0002, EXIF_FORMAT_SHORT_UNSIGNED, 1,
+					     "ISOSpeedRatings", "ISO speed", NULL };
+		ExifItem *shadow;
+
+		shadow = exif_item_new(marker.format, marker.tag, 1, &marker);
+		memcpy(shadow->data, item->data + 2, 2);
+
+		exif->items = g_list_prepend(exif->items, shadow);
+		}
+
+	item = exif_get_item(exif, "Nikon.WhiteBalance");
+	if (item && item->format == EXIF_FORMAT_STRING)
+		{
+		static ExifMarker marker = { 0x0005, EXIF_FORMAT_STRING, -1,
+					     "LightSource", "Light source", NULL };
+		ExifItem *shadow;
+
+		shadow = exif_item_new(marker.format, marker.tag, item->data_len, &marker);
+		memcpy(shadow->data, item->data, item->data_len);
+
+		exif->items = g_list_prepend(exif->items, shadow);
+		}
+
+	return TRUE;
+}
+
diff -r 7a6553f9e3c7 -r f0242547f3b5 src/format_pentax.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/format_pentax.h	Wed Sep 27 07:27:37 2006 +0000
@@ -0,0 +1,32 @@
+/*
+ *  GQView
+ *  (C) 2005 John Ellis
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef __FORMAT_PENTAX_H
+#define __FORMAT_PENTAX_H
+
+
+#include "exif.h"
+
+gint format_pentax_raw(unsigned char *data, const guint len,
+		      guint *image_offset, guint *exif_offset);
+
+#define FORMAT_RAW_PENTAX { "pef", \
+			   FORMAT_RAW_MATCH_TIFF_MAKE, 0, "PENTAX Corporation", 18, \
+			   "Pentax raw", format_pentax_raw }
+
+
+gint format_pentax_makernote(ExifData *exif, unsigned char *tiff, guint offset,
+			    guint size, ExifByteOrder bo);
+
+#define FORMAT_EXIF_PENTAX { FORMAT_EXIF_MATCH_MAKERNOTE, "PENTAX\x00", 7, "Pentax", format_pentax_makernote }, \
+			  { FORMAT_EXIF_MATCH_MAKE,      "PENTAX",     6, "Pentax", format_pentax_makernote }
+
+
+#endif
+
