kopia lustrzana https://gitlab.com/sane-project/backends
2002-08-17 Oliver Rauch <Oliver.Rauch@rauch-domain.de>
* tools/gamma4scanimage.c: NEW: tool to create gamma table for scanimage * tools/Makefile.in: changed file to compile and install gamma4scanimageDEVEL_2_0_BRANCH-1
rodzic
28edd2af4d
commit
790e5c9c25
|
@ -53,7 +53,7 @@ DISTCLEAN_FILES = @DISTCLEAN_FILES@
|
|||
|
||||
@SET_MAKE@
|
||||
|
||||
DESTINATIONS = sane-find-scanner sane-config umax_pp
|
||||
DESTINATIONS = sane-find-scanner sane-config umax_pp gamma4scanimage
|
||||
|
||||
EXTRA = sane_strstatus.lo ../sanei/sanei_init_debug.lo \
|
||||
../sanei/sanei_config.lo ../sanei/sanei_config2.lo \
|
||||
|
@ -77,12 +77,13 @@ DISTFILES = Makefile.in README libtool-get-dll-ext mustek600iin-off.c \
|
|||
|
||||
all: $(DESTINATIONS)
|
||||
|
||||
install: sane-config sane-find-scanner
|
||||
install: sane-config sane-find-scanner gamma4scanimage
|
||||
$(INSTALL_SCRIPT) sane-config $(DESTDIR)$(bindir)/sane-config
|
||||
$(INSTALL_PROGRAM) sane-find-scanner $(DESTDIR)$(bindir)/sane-find-scanner
|
||||
$(INSTALL_PROGRAM) gamma4scanimage $(DESTDIR)$(bindir)/gamma4scanimage
|
||||
|
||||
uninstall:
|
||||
rm -f $(bindir)/sane-config $(bindir)/sane-find-scanner
|
||||
rm -f $(bindir)/sane-config $(bindir)/sane-find-scanner $(bindir)/gamma4scanimage
|
||||
|
||||
sane-config: sane-config.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
|
@ -93,6 +94,8 @@ sane-find-scanner: sane-find-scanner.o ../backend/sane_strstatus.lo \
|
|||
@$(LIBTOOL) $(MLINK) $(LINK) sane-find-scanner.o \
|
||||
../backend/sane_strstatus.lo $(LIBSANEI) $(LIBLIB) $(LIBS)
|
||||
|
||||
gamma4scanimage: gamma4scanimage.o -lm
|
||||
|
||||
../backend/umax_pp_low.o: ../backend/umax_pp_low.c
|
||||
$(COMPILE) ../backend/umax_pp_low.c -o ../backend/umax_pp_low.o \
|
||||
-DBACKEND_NAME=umax_pp_low
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
double gamma = 1.0;
|
||||
int shadow = 0;
|
||||
int highlight = 16383;
|
||||
int maxin = 16383;
|
||||
int maxout = 255;
|
||||
int in, out;
|
||||
float f;
|
||||
|
||||
if ( (argc==1) || (argc>6) )
|
||||
{
|
||||
printf("Usage: %s gamma [shadow [highlight [maxin [maxout]]]]\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (argc>1)
|
||||
{
|
||||
gamma = atof(argv[1]);
|
||||
}
|
||||
|
||||
if (argc>2)
|
||||
{
|
||||
shadow = atof(argv[2]);
|
||||
}
|
||||
|
||||
if (argc>3)
|
||||
{
|
||||
highlight = atof(argv[3]);
|
||||
}
|
||||
|
||||
if (argc>4)
|
||||
{
|
||||
maxin = atof(argv[4]);
|
||||
}
|
||||
|
||||
if (argc>5)
|
||||
{
|
||||
maxout = atof(argv[5]);
|
||||
}
|
||||
|
||||
if (shadow < 0)
|
||||
{
|
||||
printf("%s error: shadow=%d < 0\n", argv[0], shadow);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (highlight < 0)
|
||||
{
|
||||
printf("%s error: highlight=%d < 0\n", argv[0], highlight);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (maxin < 0)
|
||||
{
|
||||
printf("%s error: maxin=%d < 0\n", argv[0], maxin);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (maxout < 0)
|
||||
{
|
||||
printf("%s error: maxout=%d < 0\n", argv[0], maxout);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (shadow >= highlight)
|
||||
{
|
||||
printf("%s error: shadow=%d >= highlight=%d\n", argv[0], shadow, highlight);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (highlight > maxin)
|
||||
{
|
||||
printf("%s error: highlight=%d > maxin=%d\n", argv[0], highlight, maxin);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((gamma < 0.1) || (gamma > 5))
|
||||
{
|
||||
printf("%s error: gamma=%f out of range [0.1;5]\n", argv[0], gamma);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
f = (highlight - shadow) / 255 + shadow;
|
||||
|
||||
printf("[%d]%d-", 0, 0);
|
||||
|
||||
if (shadow > 0)
|
||||
{
|
||||
printf("[%d]%d-", shadow, 0);
|
||||
}
|
||||
|
||||
while (f < highlight)
|
||||
{
|
||||
in = (int) f;
|
||||
out = maxout * pow((double) (in - shadow)/(highlight-shadow), (1.0/gamma));
|
||||
printf("[%d]%d-", in, out);
|
||||
f *= 1.5;
|
||||
}
|
||||
|
||||
if (f > highlight)
|
||||
{
|
||||
printf("[%d]%d-", highlight, maxout);
|
||||
}
|
||||
|
||||
printf("[%d]%d", maxin, maxout);
|
||||
|
||||
return 0;
|
||||
}
|
Ładowanie…
Reference in New Issue