summaryrefslogtreecommitdiff
path: root/camlibs/polaroid
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2004-01-08 10:28:08 +0000
committerMarcus Meissner <marcus@jet.franken.de>2004-01-08 10:28:08 +0000
commit5b5e7d30e04837775ddc9c4e76b83da4ec9d6e33 (patch)
tree1fcaae240008b1e4244206d28564d609f8cdc009 /camlibs/polaroid
parentfb99d67f7ec884508c44567daca5336dccb91d9d (diff)
downloadlibgphoto2-5b5e7d30e04837775ddc9c4e76b83da4ec9d6e33.tar.gz
From Mark Slemko <slemkom@users.sourceforge.net>
* dlink350f.c, dlink350f.h, pdc640.c: Orientation, byte order, and brightness correction for the D-Link 350F git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@6969 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/polaroid')
-rw-r--r--camlibs/polaroid/ChangeLog7
-rw-r--r--camlibs/polaroid/Makefile.am2
-rw-r--r--camlibs/polaroid/dlink350f.c110
-rw-r--r--camlibs/polaroid/dlink350f.h26
-rw-r--r--camlibs/polaroid/pdc640.c5
5 files changed, 147 insertions, 3 deletions
diff --git a/camlibs/polaroid/ChangeLog b/camlibs/polaroid/ChangeLog
index e3329625b..bd015529c 100644
--- a/camlibs/polaroid/ChangeLog
+++ b/camlibs/polaroid/ChangeLog
@@ -1,3 +1,10 @@
+2004-01-08 Marcus Meissner <marcus@jet.franken.de>
+
+ From Mark Slemko <slemkom@users.sourceforge.net>
+ * dlink350f.c, dlink350f.h, pdc640.c:
+ Orientation, byte order, and brightness correction for the
+ D-Link 350F
+
2004-01-04 Marcus Meissner <marcus@jet.franken.de>
* pdc640.c: Use different names for Skanhex SX-35, or
diff --git a/camlibs/polaroid/Makefile.am b/camlibs/polaroid/Makefile.am
index 3949ee96b..76862bf9c 100644
--- a/camlibs/polaroid/Makefile.am
+++ b/camlibs/polaroid/Makefile.am
@@ -12,7 +12,7 @@ INCLUDES = \
-I$(top_builddir)/libgphoto2
libgphoto2_polaroid_pdc320_la_SOURCES = pdc320.c pdc320.h
-libgphoto2_polaroid_pdc640_la_SOURCES = pdc640.c jd350e.h jd350e.c jd350e_red.h jd350e_blue.h
+libgphoto2_polaroid_pdc640_la_SOURCES = pdc640.c jd350e.h jd350e.c jd350e_red.h jd350e_blue.h dlink350f.c dlink350f.h
libgphoto2_polaroid_pdc700_la_SOURCES = pdc700.c
libgphoto2_polaroid_pdc320_la_LDFLAGS = -module -avoid-version
diff --git a/camlibs/polaroid/dlink350f.c b/camlibs/polaroid/dlink350f.c
new file mode 100644
index 000000000..d8f09a5c2
--- /dev/null
+++ b/camlibs/polaroid/dlink350f.c
@@ -0,0 +1,110 @@
+/* dlink350f.c
+ *
+ * orientation, byte order, and brightness correction for the D-Link 350F
+ *
+ * Copyright 2003 Mark Slemko <slemkom@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gphoto2-library.h>
+#include <gphoto2-port-log.h>
+
+#define GP_MODULE "dlink350f"
+
+#include "dlink350f.h"
+
+#define RED(p,x,y,w) *((p)+3*((y)*(w)+(x)) )
+#define GREEN(p,x,y,w) *((p)+3*((y)*(w)+(x))+1)
+#define BLUE(p,x,y,w) *((p)+3*((y)*(w)+(x))+2)
+
+#define SWAP(a,b) {unsigned char t=(a); (a)=(b); (b)=t;}
+
+#define MINMAX(a,min,max) { (min)=MIN(min,a); (max)=MAX(max,a); }
+
+#ifndef MAX
+# define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+#ifndef MIN
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/*
+ * function added for the D-Link DSC 350F - written by Mark Slemko - mslemko@netscape.net
+ * This function correctly adjusts the color and orientation of the image
+ */
+int dlink_dsc350f_postprocessing_and_flip_both (int width, int height, unsigned char* rgb) {
+ unsigned char *start, *end, c;
+ char hilow[128];
+
+ int whichcolor = 0;
+ int lowred=255, lowgreen=255, lowblue=255;
+ int hired=0, higreen=0, hiblue=0;
+
+ GP_DEBUG("flipping byte order");
+
+ /* flip image left/right and top/bottom (actually reverse byte order) */
+ start = rgb;
+ end = start + ((width * height) * 3);
+
+ while (start < end) {
+ c = *start;
+
+ /* validation - debugging info - collect the color range info
+ * for first half of image.
+ */
+ switch (whichcolor % 3) {
+ case 0: // blue
+ MINMAX((int)c,lowblue,hiblue);
+ break;
+ case 1: // green
+ MINMAX((int)c,lowgreen,higreen);
+ break;
+ default: // red
+ MINMAX((int)c,lowred,hired);
+ break;
+ }
+
+ /* adjust color magnitude, since it appears that the 350f only had 7 bits of color info */
+ *start++ = *--end << 1;
+ *end = c << 1;
+
+ whichcolor++;
+ }
+
+ /* // could do more color processing here
+ GP_DEBUG("adjusting color");
+
+ // adjust image colours
+ start = rgb;
+ end = start + ((width * height) * 3);
+
+ while (start < end) {
+ c = *start++;
+ }
+ */
+
+ /* show the color range of image in debug mode. */
+ sprintf(hilow, "\nred low = %d high = %d\ngreen low = %d high = %d\nblue low = %d high = %d\n", lowred,hired, lowgreen,higreen, lowblue,hiblue);
+ GP_DEBUG(hilow);
+ return GP_OK;
+}
diff --git a/camlibs/polaroid/dlink350f.h b/camlibs/polaroid/dlink350f.h
new file mode 100644
index 000000000..59eeecbc8
--- /dev/null
+++ b/camlibs/polaroid/dlink350f.h
@@ -0,0 +1,26 @@
+ /* dlink350f.h
+ *
+ * orientation, byte order, and brightness correction for the D-Link 350F
+ *
+ * Copyright 2003 Mark Slemko <slemkom@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __DLINK350F_H__
+#define __DLINK350F_H__
+int dlink_dsc350f_postprocessing_and_flip_both (int width, int height, unsigned char* rgb);
+#endif
diff --git a/camlibs/polaroid/pdc640.c b/camlibs/polaroid/pdc640.c
index 8d649a2b1..5af350eae 100644
--- a/camlibs/polaroid/pdc640.c
+++ b/camlibs/polaroid/pdc640.c
@@ -61,7 +61,8 @@
typedef enum{
pdc640,
- jd350e
+ jd350e,
+ dlink350f
} Model;
typedef int postproc_func(int,int,unsigned char*);
@@ -189,7 +190,7 @@ static struct {
/* http://www.dlink.com/products/usb/dsc350/ */
/* ids from driver download */
{"D-Link DSC 350F", 0xd64, 0x1021, {
- jd350e,
+ dlink350f,
BAYER_TILE_BGGR,
&flip_vertical,
"dlink%04i.ppm"