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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
110
camlibs/polaroid/dlink350f.c
Normal file
110
camlibs/polaroid/dlink350f.c
Normal file
@@ -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;
|
||||
}
|
||||
26
camlibs/polaroid/dlink350f.h
Normal file
26
camlibs/polaroid/dlink350f.h
Normal file
@@ -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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user