diff options
author | joerg <joerg@FreeBSD.org> | 1996-01-14 02:59:59 +0800 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-01-14 02:59:59 +0800 |
commit | 68e58ccf95debaaa25f59cdb5ab2bbc0f9aa8911 (patch) | |
tree | 80619c6c986d7857721bcd4539acb572ddbe4dc8 /graphics/hpscan | |
parent | d5046b7b88fc8369fa3ce770cb65b4be6fd462ed (diff) | |
download | freebsd-ports-graphics-68e58ccf95debaaa25f59cdb5ab2bbc0f9aa8911.tar.gz freebsd-ports-graphics-68e58ccf95debaaa25f59cdb5ab2bbc0f9aa8911.tar.zst freebsd-ports-graphics-68e58ccf95debaaa25f59cdb5ab2bbc0f9aa8911.zip |
Some additions:
. fix a minor bug, causing core dumps in some occasions
. add handling for 15/16/24/32 bit displays
. provide an Imakefile
Reviewed by: Richard Tobin, and nate
Diffstat (limited to 'graphics/hpscan')
-rw-r--r-- | graphics/hpscan/files/patch-ab | 232 | ||||
-rw-r--r-- | graphics/hpscan/files/patch-ac | 13 | ||||
-rw-r--r-- | graphics/hpscan/files/patch-ad | 17 |
3 files changed, 262 insertions, 0 deletions
diff --git a/graphics/hpscan/files/patch-ab b/graphics/hpscan/files/patch-ab new file mode 100644 index 00000000000..8ce8ea7b9fe --- /dev/null +++ b/graphics/hpscan/files/patch-ab @@ -0,0 +1,232 @@ +diff -u old/colour.c colour.c +--- old/colour.c Fri Jun 3 14:39:39 1994 ++++ colour.c Fri Jan 12 17:25:53 1996 +@@ -19,7 +19,7 @@ + + static int allocate_colours(Colormap c); + +-static unsigned long colours[6*6*6], greys[33], black, white; ++static unsigned long *colours, greys[33], black, white; + + /* + * Create a colourmap with 6 levels each of red, green and blue, +@@ -27,12 +27,19 @@ + * enough space, otherwise create a new one. + */ + ++#define shift(x) \ ++ for(i = 31, m = 0x80000000L; (m & v->x##_mask) == 0; i--, m >>= 1) \ ++ ; \ ++ x##_shift = i; ++ + Colormap create_colourmap(void) + { +- int r, g, b, n; ++ int r, g, b, n, i, m; + XColor colour; + Colormap cmap; +- ++ Visual *v; ++ int red_shift, green_shift, blue_shift; ++ + if(screendepth == 1) + { + black = BlackPixelOfScreen(screen); +@@ -51,42 +58,85 @@ + XAllocColor(display, cmap, &colour); + } + +- /* Allocate the colours */ ++ if(screendepth <= 8) ++ { ++ /* Allocate the colours */ + +- n = 0; +- for(r=0; r<256; r+=51) +- for(g=0; g<256; g+=51) +- for(b=0; b<256; b+=51) +- { +- colour.red = r * 256; +- colour.green = g * 256; +- colour.blue = b * 256; +- if(XAllocColor(display, cmap, &colour) == 0) ++ colours = (unsigned long *)malloc(6*6*6 * sizeof(unsigned long)); ++ if(colours == 0) ++ { ++ fprintf(stderr, "Out of memory allocating the colour table.\n"); ++ exit(1); ++ } ++ n=0; ++ for(r=0; r<256; r+=51) ++ for(g=0; g<256; g+=51) ++ for(b=0; b<256; b+=51) + { +- fprintf(stderr, "using private colormap\n"); +- cmap = XCopyColormapAndFree(display, cmap); +- XAllocColor(display, cmap, &colour); ++ colour.red = r * 256; ++ colour.green = g * 256; ++ colour.blue = b * 256; ++ if(XAllocColor(display, cmap, &colour) == 0) ++ { ++ fprintf(stderr, "using private colormap\n"); ++ cmap = XCopyColormapAndFree(display, cmap); ++ XAllocColor(display, cmap, &colour); ++ } ++ colours[n++] = colour.pixel; + } +- colours[n++] = colour.pixel; +- } + +- /* Allocate the greys */ ++ /* Allocate the greys */ + +- for(n=0; n<33; n++) +- { +- colour.red = colour.green = colour.blue = n * 8 * 256 - (n == 32); +- if(XAllocColor(display, cmap, &colour) == 0) ++ for(n=0; n<33; n++) + { +- fprintf(stderr, "using private colormap\n"); +- cmap = XCopyColormapAndFree(display, cmap); +- XAllocColor(display, cmap, &colour); ++ colour.red = colour.green = colour.blue = n * 8 * 256 - (n == 32); ++ if(XAllocColor(display, cmap, &colour) == 0) ++ { ++ fprintf(stderr, "using private colormap\n"); ++ cmap = XCopyColormapAndFree(display, cmap); ++ XAllocColor(display, cmap, &colour); ++ } ++ greys[n] = colour.pixel; + } +- greys[n] = colour.pixel; +- } + +- black = greys[0]; +- white = greys[32]; ++ black = greys[0]; ++ white = greys[32]; ++ } ++ else /* > 8 bit, assume truecolor display */ ++ { ++ /* Use a 5*5*5 truecolor map */ ++ colours = (unsigned long *)malloc(32768 * sizeof(unsigned long)); ++ if(colours == 0) ++ { ++ fprintf(stderr, "Out of memory allocating the colour table.\n"); ++ exit(1); ++ } ++ ++ v = DefaultVisualOfScreen(screen); ++ shift(red); ++ shift(green); ++ shift(blue); ++ n=0; ++ for(r=0; r<32; r++) ++ for(g=0; g<32; g++) ++ for(b=0; b<32; b++) ++ { ++ /* ++ * We assume the default colormap has a certain ++ * format, so we can compute the pixel values ++ * without asking the XServer (which would take a ++ * tremendous amount of time for 32k colours). ++ */ ++ colours[n++] = ++ (r << (red_shift - 4)) | ++ (g << (green_shift - 4)) | ++ (b << (blue_shift - 4)); ++ } + ++ black = BlackPixelOfScreen(screen); ++ white = WhitePixelOfScreen(screen); ++ } ++ + return cmap; + } + +@@ -112,7 +162,7 @@ + pix_best = black; + } + } +- else ++ else if(screendepth <= 8) + { + int min = r < g ? (r < b ? r : b) : (g < b ? g : b); + int max = r > g ? (r > b ? r : b) : (g > b ? g : b); +@@ -131,6 +181,21 @@ + b_best = ((b + 25) / 51) * 51; + + pix_best = colours[(r_best/51)*36 + (g_best/51)*6 + (b_best/51)]; ++ } ++ } ++ else /* > 8 bit */ ++ { ++ if(r == 255 && g == 255 && b == 255) ++ pix_best = white; ++ else if(r == 0 && g == 0 && b == 0) ++ pix_best = black; ++ else ++ { ++ r_best = ((r + 4) / 8) * 8; ++ g_best = ((g + 4) / 8) * 8; ++ b_best = ((b + 4) / 8) * 8; ++ ++ pix_best = colours[(r_best/8)*1024 + (g_best/8)*32 + (b_best/8)]; + } + } + +diff -u old/gui.c gui.c +--- old/gui.c Thu Jul 28 14:53:01 1994 ++++ gui.c Fri Jan 12 17:25:53 1996 +@@ -129,6 +129,7 @@ + + display = XtDisplay(shell); + screen = XtScreen(shell); ++ screendepth = DefaultDepthOfScreen(screen); + root = RootWindowOfScreen(screen); + + form = +@@ -555,21 +556,39 @@ + XImage *im; + unsigned char *newdata, *p; + int x, y; ++ int pad; + ++ switch(screendepth) ++ { ++ case 1: ++ case 8: ++ pad = 8; break; ++ case 15: ++ case 16: ++ pad = 16; break; ++ case 24: ++ case 32: ++ pad = 32; break; ++ default: ++ fprintf(stderr, "Don't know how to handle depth %d\n", screendepth); ++ return 0; ++ } ++ + if(!raw) + return 0; + + switch(raw->type) + { + case 5: /* 24 bit colour */ +- newdata = malloc(raw->width * raw->height); ++ newdata = malloc(raw->width * raw->height * (pad / 8)); + if(!newdata) + { + fprintf(stderr, "Can't malloc %d bytes\n", raw->width*raw->height); + return 0; + } +- im = XCreateImage(display, visual, 8, ZPixmap, 0, newdata, +- raw->width, raw->height, 8, raw->width); ++ im = XCreateImage(display, visual, screendepth, ZPixmap, 0, newdata, ++ raw->width, raw->height, pad, ++ raw->width * (pad/8)); + + /* Convert to fixed colour map using simple error propagation */ + diff --git a/graphics/hpscan/files/patch-ac b/graphics/hpscan/files/patch-ac new file mode 100644 index 00000000000..fe30197297c --- /dev/null +++ b/graphics/hpscan/files/patch-ac @@ -0,0 +1,13 @@ +diff -u old/gui.c gui.c +--- old/gui.c Thu Jul 28 14:53:01 1994 ++++ gui.c Fri Jan 12 17:25:53 1996 +@@ -646,7 +665,7 @@ + + for(y=MARGIN; y<raw->height-MARGIN; y++) + { +- p = raw->data + (y * raw->width + MARGIN) * 3; ++ p = raw->data + y * raw->width + MARGIN * 3; + + for(x=MARGIN; x<raw->width-MARGIN; x++) + { +Only in work: oldmain.c diff --git a/graphics/hpscan/files/patch-ad b/graphics/hpscan/files/patch-ad new file mode 100644 index 00000000000..f933508eaf2 --- /dev/null +++ b/graphics/hpscan/files/patch-ad @@ -0,0 +1,17 @@ +--- /dev/null Sat Jan 13 17:05:14 1996 ++++ Imakefile Fri Jan 12 17:49:11 1996 +@@ -0,0 +1,14 @@ ++XCOMM ++XCOMM Imakefile for Richard Tobin's HP scanner utility, ++XCOMM written by Jörg Wunsch, 96/01/12. ++XCOMM ++ ++ EXTRA_INCLUDES = -I/sys ++ ++ DEPLIBS = XawClientDepLibs ++LOCAL_LIBRARIES = XawClientLibs MathLibrary ++ ++ SRCS = main.c scsi.c scanner.c scl.c gui.c colour.c Plain.c ++ OBJS = main.o scsi.o scanner.o scl.o gui.o colour.o Plain.o ++ ++ComplexProgramTarget(hpscan) |