home *** CD-ROM | disk | FTP | other *** search
- From: gunnar@falcon.ericsson.se (Was a Sunny day)
- Newsgroups: alt.sources
- Subject: Scantool part 4(5) (shar)
- Message-ID: <1991Jun18.124909.11256@ericsson.se>
- Date: 18 Jun 91 12:49:09 GMT
-
- #!/bin/sh
- # this is scan.04 (part 4 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file scan_extern.h continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 4; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping scan_extern.h'
- else
- echo 'x - continuing file scan_extern.h'
- sed 's/^X//' << 'SHAR_EOF' >> 'scan_extern.h' &&
- X */
- X
- extern char finalimage[] ; /* Name of uncompressed image file. */
- extern char line[] ;
- extern char picname[] ; /* Name of file for raster image. */
- extern char progname[] ; /* This programs name. */
- extern char temphead[] ; /* Temporary filename for header file. */
- extern char tempimage[] ; /* Temporary filename for saved scanned data. */
- X
- extern int finished ; /* Indicates if we have finished uncompressing. */
- extern int fwidth ; /* Final width of rasterfile. */
- extern int height ; /* Height in scan lines of raster file image. */
- extern int rc ; /* Current character from scanned file. */
- extern int rcount ; /* Bit position count within read character. */
- extern int wc ; /* Current char to write to final image file. */
- extern int wcount ; /* Bit position count within write character. */
- extern int width ; /* Width in pixels of rasterfile image. */
- X
- extern struct code *whites[] ; /* White initial starting pointers. */
- extern struct code *blacks[] ; /* Black initial starting pointers. */
- X
- extern FILE *rd ; /* File descriptor for input files. */
- extern FILE *wd ; /* File descriptor for final image. */
- SHAR_EOF
- echo 'File scan_extern.h is complete' &&
- chmod 0644 scan_extern.h ||
- echo 'restore of scan_extern.h failed'
- Wc_c="`wc -c < 'scan_extern.h'`"
- test 1744 -eq "$Wc_c" ||
- echo 'scan_extern.h: original size 1744, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool.1 ==============
- if test -f 'scantool.1' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool.1 (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool.1 (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool.1' &&
- .\" @(#)scantool.1 1.3 90/04/04
- .TH SCANTOOL 1L "2 April 1990"
- .SH NAME
- scantool \- a program to scan images using a Microtek MS300A scanner.
- .SH SYNOPSIS
- .B "scantool
- [
- .B -v
- ]
- [
- .B \-Wi
- ]
- [
- .B \-Wp
- .I x y
- ]
- [
- .B \-WP
- .I x y
- ]
- .SH DESCRIPTION
- .I Scantool
- allows the user to scan in documents using a Microtek
- MS300A scanner, and turn the resulting image into a Sun rasterfile.
- This program uses either SunView or XView graphics. These graphics
- routines are fairly trivial, and have been isolated into a single
- file, so it would be relatively easy to write a set of graphics
- routines for another graphics system.
- .LP
- When you run scantool, a window is displayed. There is a black bar
- at the top with containing six headings. Hitting a mouse button when
- the cursor is above one of those six headings, will display a popup
- menu. These options are explained in more detail below, and also by
- selecting entries from the Help popup menu.
- .LP
- There are also four box toggle switches. Each toggle has two settings.
- There are toggles for setting the line mode,
- data transfer method, serial port and baud rate.
- .LP
- There are three buttons. The Scan button initiates a scan. Should you
- wish to cancel a scan once it has been started, then you should press
- the Canel button.
- .LP
- The Show button allows you to display the scanned rasterfile images in
- a separate window.
- .SS "Display mode."
- .LP
- The scanner can handle input from the image sensor in
- two modes: Line Art mode and Halftone mode. Line Art
- mode produces an all black-and-white image, while
- Halftone mode results in an image that appears to contain
- varying shades of gray.
- .LP
- In Line Art mode, the amount of light falling on the
- sensor is compared against a "threshold" determined by
- the Brightness and Contrast controls. Whenever it falls
- below the threshold, a black dot is sent to the Sun; when
- it exceeds the threshold a white dot is sent. This mode
- is normally used for material in which everything is
- either black or white.
- .LP
- Halftone mode is used to detect and reproduce finer
- differences in shading. In this mode the dots sent to
- the Sun are organised into squares, or "grains", of
- uniform size. By varying the ratio of black and white
- dots in the grains, different degrees of shading, or
- "gray levels", are achieved.
- .SS "Data transfer."
- .LP
- In order to reduce the amount of time needed to
- transmit a scanned image to the computer, the
- MS-300A can compress image data using a one-
- dimensional coding scheme based on CCITT
- Recommendation T.4 (modified Huffman code). By default the scanner
- will send compressed data to the computer.
- .SS " Serial connection."
- .LP
- The scanner connects to the computer using an RS232 connection.
- This is currently setup to allow you to select between the RS232
- A and B ports. The baud rate can also be toggled between 9600
- and 1920 baud.
- .SS "Brightness."
- .LP
- There are 14 Brightness levels to choose from. The
- effect of this control depends on whether the image
- is scanned in Line Art or Halftone mode.
- .LP
- In Line Art mode, the higher the Brightness setting
- the darker a spot must be in order for the scanner to
- consider it "black". Lower settings can therefore be
- used to get a sharper image if the original is too
- light or blurry, while higher settings can be used to
- prevent slightly shaded areas from coming out black
- in the scanned image.
- .LP
- In Halftone mode, the Brightness setting affects
- shading in all areas of the scanned image, both dark
- and light. The higher the value selected, the lighter
- the overall image; the lower the setting, the darker image.
- .SS "Contrast."
- .LP
- The Contrast control also has 14 different settings.
- The effect of this control in Line Art mode is identical
- to that of the Brightness control. In Halftone mode, a
- higher Contrast setting causes all but the darkest areas
- of the original document to come out lighter in the
- scanned image. Too high a setting can result in "glare
- spots" of pure white; too low a setting can make the
- image almost uniformly gray.
- .SS "Grain."
- .LP
- All the grains in any one halftone image are the same
- size (see the Mode help). It is desirable, however, to
- use different grain sizes for different kinds of images.
- The Grain control makes it possible to do this. Six
- different grain sizes are available: 2, 3, 4, 5, 6, and
- 8 dots square.
- .LP
- When smaller grain sizes (i.e. higher settings) are
- used, fine details in the original document are captured
- more clearly, but the smaller number of dot positions in
- the grains limits the scanner's "palette" of gray levels.
- A Grain setting of 11, for instance produces grains that
- are 2 dots high by 2 dots wide. With only 4 dot positions
- to fill, only 5 distinct gray levels are possible, from
- all white to all black.
- .SS "Resolution."
- .LP
- The Resolution control determines the degree of
- reduction of the scanned image relative to the original.
- Since the dots that make up the scanned image cannot be
- reduced in size, reduction is achieved by deleting dots
- at selected intervals when transmitting the image to
- the Sun, resulting in an effective resolution of less
- than the scanner's maximum of 300 dots per inch.
- .LP
- There are 16 possible Resolution settings, providing
- scaling operations from 25% to 100%.
- .SS "Setting the picture name."
- .LP
- There are various options that can be set via the Set popup menu.
- One of these is the picture name. This is the name of the file on
- the Sun that the scanned picture will be saved in. The default is
- a file called "Noname.rf".
- .SS "Setting the scaning frame."
- .LP
- The frame is the area to be scanned. Scantool allows
- you to scan an area as small as 1/8" x 1/8", or as large
- as 8.5" x 11". Using the Set Scanning Frame function in
- the Set menu, you can adjust the size and location of
- the frame in order to scan any part of the document that
- you feed into the scanner.
- .SS "Initiating a scan."
- .LP
- When you click the Scan button, scantool checks
- to see if the scanner is on line, i.e. powered up,
- properly connected and ready to receive commands.
- .LP
- If everything checks out OK, the current settings
- will be transmitted to the scanner, and the rollers
- will begin to turn. Actual scanning will begin after
- a document is detected by the paper sensor, which is
- located in the middle of the feed slot just below
- the top rollers.
- .SH OPTIONS
- .TP
- .B \-v
- Print the version number of this release of the scantool program.
- .TP
- .B \-Wi
- Start the
- .B scantool
- program up in iconic form.
- .TP
- .BI \-Wp " x y"
- Start the open window position at
- .I x y
- .TP
- .BI \-WP " x y"
- Start the icon position at
- .I x y
- .SH FILES
- .TP
- /usr/local/lib/scantool/scantool.help
- .SH AUTHOR
- Rich Burridge, Domain: richb@Aus.Sun.COM
- .nf
- PHONE: +61 2 413 2666 Path: {uunet,mcvax,ukc}!munnari!sunaus.oz!richb
- .fi
- SHAR_EOF
- chmod 0644 scantool.1 ||
- echo 'restore of scantool.1 failed'
- Wc_c="`wc -c < 'scantool.1'`"
- test 6726 -eq "$Wc_c" ||
- echo 'scantool.1: original size 6726, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool.c ==============
- if test -f 'scantool.c' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool.c' &&
- X
- /* @(#)scantool.c 1.4 90/04/04
- X *
- X * Main routine for scantool, which will read a scanned image
- X * from a Microtek MS-300A scanner and convert it to a Sun rasterfile.
- X *
- X * Copyright (c) Rich Burridge.
- X * Sun Microsystems, Australia - All rights reserved.
- X *
- X * Permission is given to distribute these sources, as long as the
- X * copyright messages are not removed, and no monies are exchanged.
- X *
- X * No responsibility is taken for any errors or inaccuracies inherent
- X * either to the comments or the code of this program, but if
- X * reported to me, then an attempt will be made to fix them.
- X */
- X
- #include <stdio.h>
- #include <strings.h>
- #include "scantool.h"
- X
- char *br_strs[] = { /* Brightness menu item strings. */
- X "1 -24% Darker",
- X "2 -20% Darker",
- X "3 -16% Darker",
- X "4 -12% Darker",
- X "5 -8% Darker",
- X "6 -4% Darker",
- X "7 No adjustment",
- X "8 +4% Lighter",
- X "9 +8% Lighter",
- X "10 +12% Lighter",
- X "11 +16% Lighter",
- X "12 +20% Lighter",
- X "13 +24% Lighter",
- X "14 +28% Lighter",
- X NULL
- } ;
- X
- char *con_strs[] = { /* Contrast menu item strings. */
- X "1 -24% Lower",
- X "2 -20% Lower",
- X "3 -16% Lower",
- X "4 -12% Lower",
- X "5 -8% Lower",
- X "6 -4% Lower",
- X "7 No adjustment",
- X "8 +4% Higher",
- X "9 +8% Higher",
- X "10 +12% Higher",
- X "11 +16% Higher",
- X "12 +20% Higher",
- X "13 +24% Higher",
- X "14 +28% Higher",
- X NULL
- } ;
- X
- char *gr_strs[] = { /* Grain menu item strings. */
- X "0 Grain Size: 8x8 Gray Levels: 33",
- X "1 Grain Size: 8x8 Gray Levels: 33",
- X "2 Grain Size: 8x8 Gray Levels: 33",
- X "3 Grain Size: 8x8 Gray Levels: 33",
- X "4 Grain Size: 6x6 Gray Levels: 37",
- X "5 Grain Size: 5x5 Gray Levels: 26",
- X "6 Grain Size: 5x5 Gray Levels: 18",
- X "7 Grain Size: 4x4 Gray Levels: 17",
- X "8 Grain Size: 4x4 Gray Levels: 17",
- X "9 Grain Size: 4x4 Gray Levels: 17",
- X "10 Grain Size: 3x3 Gray Levels: 10",
- X "11 Grain Size: 2x2 Gray Levels: 5",
- X NULL
- } ;
- X
- char *help_strs[] = { /* Help menu item strings. */
- X "Brightness",
- X "Contrast",
- X "Frame",
- X "Grain",
- X "Mode",
- X "Resolution",
- X "Scan",
- X "Compress",
- X "Port",
- X "Speed",
- X "Picture",
- X NULL
- } ;
- X
- char *res_strs[] = { /* Resolution menu item strings. */
- X "0 300 dpi Scale: Full size",
- X "1 285 dpi Scale: 95%",
- X "2 270 dpi Scale: 90%",
- X "3 255 dpi Scale: 85%",
- X "4 240 dpi Scale: 80%",
- X "5 225 dpi Scale: 75%",
- X "6 210 dpi Scale: 70%",
- X "7 200 dpi Scale: 66%",
- X "8 180 dpi Scale: 60%",
- X "9 165 dpi Scale: 55%",
- X "10 150 dpi Scale: 50%",
- X "11 135 dpi Scale: 45%",
- X "12 120 dpi Scale: 40%",
- X "13 100 dpi Scale: 33%",
- X "14 90 dpi Scale: 30%",
- X "15 75 dpi Scale: 25%",
- X NULL
- } ;
- X
- char *set_strs[] = { /* Set menu item strings. */
- X "Picture Name",
- X "Default Settings",
- X "Clear Scanning Frame",
- X "New Scanning Frame",
- X "Show Current Settings",
- X NULL
- } ;
- X
- char helpname[MAXLINE] ; /* Current help file to display. */
- char last_message[MAXLINE] ; /* Last message that was make_displayed. */
- char old_picname[MAXLINE] ; /* Previous picture name. */
- char output[MAXLINE] ; /* Panel_set string to be output. */
- char picname[MAXLINE] ; /* Name of file for raster image. */
- char progname[MAXLINE] ; /* Name of this program. */
- X
- int ops[MAXOPS] ; /* Rasterop functions. */
- X
- int switches[4] =
- X {
- X 0, /* Mode (Line Art). */
- X 1, /* Data Transfer (Compressed). */
- X 0, /* Serial Port (A). */
- X 1 /* Baud Rate (19200). */
- X } ;
- X
- int framevals[4] = /* Initial frame in 1/8th inch intervals. */
- X {
- X 16, /* X1. */
- X 16, /* Y1. */
- X 48, /* X2. */
- X 48, /* Y2. */
- X } ;
- X
- int butx ; /* Top left X position of popup button. */
- int buty ; /* Top left Y position of popup button. */
- int cur_ch ; /* Last keyboard character pressed. */
- int curx ; /* Current X position of the mouse. */
- int cury ; /* Current Y position of the mouse. */
- int font_width ; /* Width of a single character. */
- int nohelp = 0 ; /* Indicates if a help file was found. */
- int pid ; /* Process id of the child scan process. */
- int scanning = 0 ; /* Set if we are in the middle of a scan. */
- int showing = 0 ; /* Set if we are in the middle of a show. */
- int type ; /* Current pseudo event type. */
- int width ; /* Width in pixels of scantool window. */
- X
- /* Cyclic switches. */
- int brightness ; /* Brightness value. */
- int contrast ; /* Contrast value. */
- int grain ; /* Grain value. */
- int resolution ; /* Resolution value. */
- X
- enum draw_type drawstate ; /* Current action if a redraw is needed. */
- X
- FILE *hfd ; /* File descriptor for help file. */
- X
- X
- main(argc, argv)
- int argc ;
- char *argv[] ;
- {
- X STRCPY(progname, argv[0]) ; /* Save program name. */
- X get_options(argc, argv) ; /* Extract command line options. */
- X init_ws_type() ; /* Setup pseudo rasterop functions. */
- X drawstate = DO_NOTHING ; /* No popups currently displayed. */
- X if ((hfd = fopen(HELPNAME, "r")) == NULL)
- X {
- X FPRINTF(stderr, "Help file %s not found\r\n", HELPNAME) ;
- X nohelp = 1 ;
- X }
- X
- X STRCPY(picname, "/home1/falcon/gunnar/scan.rf") ;
- X set_defaults() ; /* Set scanner settings to default. */
- X make_frames(argc, argv) ; /* Create main scantool frame and show window. */
- X make_subframes() ; /* Create canvases for each window. */
- X init_fonts() ; /* Open fonts used by scantool. */
- X make_menus() ; /* Create scantool menubar pulldown menus. */
- X start_tool() ; /* Fit window and wait for events. */
- }
- SHAR_EOF
- chmod 0644 scantool.c ||
- echo 'restore of scantool.c failed'
- Wc_c="`wc -c < 'scantool.c'`"
- test 6453 -eq "$Wc_c" ||
- echo 'scantool.c: original size 6453, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool.h ==============
- if test -f 'scantool.h' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool.h' &&
- X
- /* @(#)scantool.h 1.4 90/04/04
- X *
- X * Definitions used by scantool.
- X *
- X * Copyright (c) Rich Burridge.
- X * Sun Microsystems, Australia - All rights reserved.
- X *
- X * Permission is given to distribute these sources, as long as the
- X * copyright messages are not removed, and no monies are exchanged.
- X *
- X * No responsibility is taken for any errors or inaccuracies inherent
- X * either to the comments or the code of this program, but if
- X * reported to me, then an attempt will be made to fix them.
- X */
- X
- #define CLOSE (void) close /* To make lint happy. */
- #define EXECL (void) execl
- #define FGETS (void) fgets
- #define FPRINTF (void) fprintf
- #define KILL (void) kill
- #define READ (void) read
- #define SPRINTF (void) sprintf
- #define STRCPY (void) strcpy
- #define STRNCAT (void) strncat
- #define STRNCPY (void) strncpy
- X
- #define BUTTON_HEIGHT 28 /* Height of a command button in pixels. */
- #define BUTTON_WIDTH 64 /* Width of a command button in pixels. */
- #define EQUAL !strcmp /* For character comparisons. */
- #define FONT_HEIGHT 14 /* Dimensions of the character fonts used. */
- #define FRAMEGAP LINEGAP / 2 /* Scanning frame interval. */
- X
- #ifndef HELPNAME
- #define HELPNAME "scantool.help" /* Name of scantool help file. */
- #endif /*HELPNAME*/
- X
- #define INC argc-- ; argv++ ;
- #define LINEGAP 10 /* Gap between lines in scanning frame. */
- #define MAXCURSORS 4 /* Maximum number of cursors used. */
- #define MAXFONTS 2 /* Maximum number of fonts used. */
- #define MAXIMAGES 5 /* Maximum number of graphics images. */
- #define MAXLINE 80 /* Length of character strings. */
- #define MAXMENUS 6 /* Maximum number of popup menus. */
- #define MAXOPS 6 /* Number of pseudo rasterop functions. */
- #define MBAR_HEIGHT 20 /* Height of the top menu bar. */
- #define MBAR_WIDTH 100 /* Width of a portion of the top menu bar. */
- #define OFF 0 /* Used to define toggle switch positions. */
- #define ON 1
- #define SCAN_FRAME_X 26 /* Initial start position of scanning frame. */
- #define SCAN_FRAME_Y 47
- #define SCAN_HEIGHT 506 /* Height of the scantool window. */
- #define SCAN_WIDTH 600 /* Width of the scantool window. */
- #define SWITCH_HEIGHT 90 /* Height of a toggle box switch. */
- X
- #define X1 0 /* Coordinate values within framevals. */
- #define Y1 1
- #define X2 2
- #define Y2 3
- X
- #define OK 1 /* Text button states. */
- #define CANCEL 0
- X
- #define BACKSPACE 8 /* Used for filename construction. */
- #define DEL 127
- #define LINEFEED 13
- #define RETURN 10
- X
- /* Pseudo events generated by scantool. */
- #define LEFT_DOWN 0 /* Left mouse button was depressed. */
- #define LEFT_UP 1 /* Left mouse button was debounced. */
- #define MIDDLE_DOWN 2 /* Middle mouse button was depressed. */
- #define MIDDLE_UP 3 /* Middle mouse button was debounced. */
- #define RIGHT_DOWN 4 /* Right mouse button was depressed. */
- #define RIGHT_UP 5 /* Right mouse button was debounced. */
- #define KEYBOARD 6 /* A keyboard key has been pressed. */
- #define REPAINT 7 /* Scantool canvas needs repainting. */
- #define MOUSE_MOVE 8 /* The mouse is being moved. */
- #define MOUSE_DRAG 9 /* The mouse is being dragged. */
- #define IGNORE 10 /* Not interested in this event. */
- X
- /* Abbreviations for box switch values. */
- #define MODE switches[0]
- #define DATA_TRANSFER switches[1]
- #define SERIAL_PORT switches[2]
- #define BAUD_RATE switches[3]
- X
- #define SET_PICTURE 1 /* Values for the Set menu commands. */
- #define SET_DEFAULTS 2
- #define SET_CLEAR_FRAME 3
- #define SET_NEW_FRAME 4
- #define SET_CURRENT 5
- X
- /* Cursor types used by scantool. */
- enum cur_type { FRAME_CUR, HELP_CUR, HOUR_CUR, MAIN_CUR } ;
- X
- /* States that the drawing canvas can be in. */
- enum draw_type { DO_NOTHING, DO_PICNAME, DO_MESSAGE, DO_HELP, DO_SETTINGS } ;
- X
- enum font_type { BFONT, NFONT } ; /* Fonts used by scantool. */
- X
- /* Various images types used by scantool. */
- enum image_type { B_NORMAL, B_INVERT, S_NORMAL, S_INVERT,
- X M_NORMAL, M_INVERT, EXCLAIM_IMAGE } ;
- X
- /* Menus used by scantool. */
- enum menu_type { BRIGHTNESS_M, CONTRAST_M, GRAIN_M, HELP_M,
- X RESOLUTION_M, SET_M, WINDOW_M } ;
- X
- /* Pseudo rasterop functions. */
- enum op_type { GSET, GCLR, GXOR, GSRC, GOR, GNOT } ;
- X
- enum sten_type { STEN_OFF, STEN_ON, STEN_INV } ; /* Text stencil types. */
- X
- #ifndef LINT_CAST
- #ifdef lint
- #define LINT_CAST(arg) (arg ? 0 : 0)
- #else
- #define LINT_CAST(arg) (arg)
- #endif lint
- #endif LINT_CAST
- SHAR_EOF
- chmod 0644 scantool.h ||
- echo 'restore of scantool.h failed'
- Wc_c="`wc -c < 'scantool.h'`"
- test 4982 -eq "$Wc_c" ||
- echo 'scantool.h: original size 4982, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool.help ==============
- if test -f 'scantool.help' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool.help (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool.help (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool.help' &&
- %brightness%
- X BRIGHTNESS.
- X
- X There are 14 Brightness levels to choose from. The
- effect of this control depends on whether the image
- is scanned in Line Art or Halftone mode.
- X
- X In Line Art mode, the higher the Brightness setting
- the darker a spot must be in order for the scanner to
- consider it "black". Lower settings can therefore be
- used to get a sharper image if the original is too
- light or blurry, while higher settings can be used to
- prevent slightly shaded areas from coming out black
- in the scanned image.
- X
- X In Halftone mode, the Brightness setting affects
- shading in all areas of the scanned image, both dark
- and light. The higher the value selected, the lighter
- the overall image; the lower the setting, the darker
- image.
- %%
- X
- %compress%
- X COMPRESS.
- X
- X In order to reduce the amount of time needed to
- transmit a scanned image to the Sun computer, the
- MS-300A can compress image data using a one-
- dimensional coding scheme based on CCITT
- Recommendation T.4 (modified Huffman code).
- %%
- X
- %contrast%
- X CONTRAST.
- X
- X The Contrast control also has 14 different settings.
- The effect of this control in Line Art mode is identical
- to that of the Brightness control. In Halftone mode, a
- higher Contrast setting causes all but the darkest areas
- of the original document to come out lighter in the
- scanned image. Too high a setting can result in "glare
- spots" of pure white; too low a setting can make the
- image almost uniformly gray.
- %%
- X
- %frame%
- X SET SCANNING FRAME.
- X
- X The frame is the area to be scanned. Scan Tool allows
- you to scan an area as small as 1/8" x 1/8", or as large
- as 8.5" x 11". Using the Set Scanning Frame function in
- the Set menu, you can adjust the size and location of
- the frame in order to scan any part of the document that
- you feed into the scanner.
- %%
- X
- %grain%
- X GRAIN.
- X
- X All the grains in any one halftone image are the same
- size (see the Mode help). It is desirable, however, to
- use different grain sizes for different kinds of images.
- The Grain control makes it possible to do this. Six
- different grain sizes are available: 2, 3, 4, 5, 6, and
- 8 dots square.
- X
- X When smaller grain sizes (i.e. higher settings) are
- used, fine details in the original document are captured
- more clearly, but the smaller number of dot positions in
- the grains limits the scanner's "palette" of gray levels.
- A Grain setting of 11, for instance produces grains that
- are 2 dots high by 2 dots wide. With only 4 dot positions
- to fill, only 5 distinct gray levels are possible, from
- all white to all black.
- %%
- X
- %mode%
- X MODE.
- X
- X The scanner can handle input from the image sensor in
- two modes: Line Art mode and Halftone mode. Line Art
- mode produces an all black-and-white image, while
- Halftone mode results in an image that appears to contain
- varying shades of gray.
- X
- X In Line Art mode, the amount of light falling on the
- sensor is compared against a "threshold" determined by
- the Brightness and Contrast controls. Whenever it falls
- below the threshold, a black dot is sent to the Sun; when
- it exceeds the threshold a white dot is sent. This mode
- is normally used for material in which everything is
- either black or white.
- X
- X Halftone mode is used to detect and reproduce finer
- differences in shading. In this mode the dots sent to
- the Sun are organised into squares, or "grains", of
- uniform size. By varying the ratio of black and white
- dots in the grains, different degrees of shading, or
- "gray levels", are achieved.
- %%
- X
- %picture%
- X PICTURE NAME.
- X
- X This is the name of the file on the Sun that the
- scanned picture will be saved in. The default is a
- file called "Noname.rf".
- %%
- X
- %port%
- X PORT.
- X
- X This is the RS232 port that is used to connect to
- the scanner. Connect the MS300-A to the Sun as shown
- below:
- X
- X MS-300A SUN
- X ------------ ----------
- X Pin No. Name Direction Pin No. Name
- X --------- ------ -------------- --------- ------
- X 2 TXD Scanner to Sun 3 RXD
- X 3 RXD Sun to scanner 2 TXD
- X 7 GND --- 7 GND
- %%
- X
- %resolution%
- X RESOLUTION.
- X
- X The Resolution control determines the degree of
- reduction of the scanned image relative to the original.
- Since the dots that make up the scanned image cannot be
- reduced in size, reduction is achieved by deleting dots
- at selected intervals when transmitting the image to
- the Sun, resulting in an effective resolution of less
- than the scanner's maximum of 300 dots per inch.
- X
- X There are 16 possible Resolution settings, providing
- scaling operations from 25% to 100%.
- %%
- X
- %scan%
- X SCAN.
- X
- X When you click the Scan button, scantool checks
- to see if the scanner is on line, i.e. powered up,
- properly connected and ready to receive commands.
- X
- X If everything checks out OK, the current settings
- will be transmitted to the scanner, and the rollers
- will begin to turn. Actual scanning will begin after
- a document is detected by the paper sensor, which is
- located in the middle of the feed slot just below
- the top rollers.
- %%
- X
- %speed%
- X SPEED.
- X
- X Two speed settings between the scanner and the
- Sun are available, either 9600 or 19200 baud.
- %%
- SHAR_EOF
- chmod 0644 scantool.help ||
- echo 'restore of scantool.help failed'
- Wc_c="`wc -c < 'scantool.help'`"
- test 5356 -eq "$Wc_c" ||
- echo 'scantool.help: original size 5356, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool.icon ==============
- if test -f 'scantool.icon' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool.icon (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool.icon (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool.icon' &&
- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
- X */
- X 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x83E0,0x0000,0x0000,0x0001,0x8630,0x0000,0x0000,0x0001,
- X 0x8630,0x0000,0x0000,0x0001,0x8301,0xF0F0,0xBC00,0x0001,
- X 0x81C3,0x1998,0xE600,0x0001,0x8063,0x0018,0xC600,0x0001,
- X 0x8033,0x00F8,0xC600,0x0001,0x8633,0x0198,0xC600,0x0001,
- X 0x8633,0x1998,0xC600,0x0001,0x83E1,0xF0FC,0xC600,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8FFF,0xFFFF,0xFFFF,0xFFF1,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8FFF,0xFFFF,0xFFFF,0xFFF1,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8FF0,0x0000,0x7800,0x0001,0x8180,0x0000,0x1800,0x0001,
- X 0x8180,0x0000,0x1800,0x0001,0x8181,0xF0F8,0x1800,0x0001,
- X 0x8183,0x198C,0x1800,0x0001,0x8183,0x198C,0x1800,0x0001,
- X 0x8183,0x198C,0x1800,0x0001,0x8183,0x198C,0x1800,0x0001,
- X 0x8183,0x198C,0x1800,0x0001,0x8181,0xF0F8,0x1800,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
- X 0x8000,0x0000,0x0000,0x0001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
- SHAR_EOF
- chmod 0644 scantool.icon ||
- echo 'restore of scantool.icon failed'
- Wc_c="`wc -c < 'scantool.icon'`"
- test 1933 -eq "$Wc_c" ||
- echo 'scantool.icon: original size 1933, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= scantool_extern.h ==============
- if test -f 'scantool_extern.h' -a X"$1" != X"-c"; then
- echo 'x - skipping scantool_extern.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scantool_extern.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scantool_extern.h' &&
- X
- /* @(#)scantool_extern.h 1.4 90/04/04
- X *
- X * External variables used by the scantool routines.
- X *
- X * Copyright (c) Rich Burridge.
- X * Sun Microsystems, Australia - All rights reserved.
- X *
- X * Permission is given to distribute these sources, as long as the
- X * copyright messages are not removed, and no monies are exchanged.
- X *
- X * No responsibility is taken for any errors or inaccuracies inherent
- X * either to the comments or the code of this program, but if
- X * reported to me, then an attempt will be made to fix them.
- X */
- X
- extern char *br_strs[] ; /* Brightness menu item strings. */
- extern char *con_strs[] ; /* Contrast menu item strings. */
- extern char *gr_strs[] ; /* Grain menu item strings. */
- extern char helpname[] ; /* Current help file to display. */
- extern char *help_strs[] ; /* Help menu item strings. */
- extern char last_message[] ; /* Last make_displayed message. */
- extern char old_picname[] ; /* Previous picture name. */
- extern char output[] ; /* Panel_set string to be output. */
- extern char picname[] ; /* Name of file for raster image. */
- extern char progname[] ; /* This programs name. */
- extern char *res_strs[] ; /* Resolution menu item strings. */
- extern char *set_strs[] ; /* Set menu item strings. */
- X
- extern int brightness ; /* Brightness value. */
- extern int butx ; /* Top left X position of popup button. */
- extern int buty ; /* Top left Y position of popup button. */
- extern int contrast ; /* Contrast value. */
- extern int cur_ch ; /* Last keyboard character pressed. */
- extern int curx ; /* Current X position of the mouse. */
- extern int cury ; /* Current Y position of the mouse. */
- extern int font_width ; /* Width of a single character. */
- extern int framevals[] ; /* Initial frame in 1/8th inch intervals. */
- extern int grain ; /* Grain value. */
- extern int nohelp ; /* Indicates if a help file was found. */
- extern int ops[] ; /* Pseudo rasterop functions. */
- extern int pid ; /* Process id of the child scan process. */
- extern int resolution ; /* Resolution value. */
- extern int scanning ; /* Set if we are in the middle of a scan. */
- extern int showing ; /* Set if we are in the middle of a show. */
- extern int switches[] ;
- extern int type ; /* Current pseudo event type. */
- extern int width ; /* Width in pixels of scantool window. */
- X
- extern FILE *hfd ; /* File descriptor for help file. */
- X
- extern enum draw_type drawstate ; /* Current redraw action. */
- X
- SHAR_EOF
- chmod 0644 scantool_extern.h ||
- echo 'restore of scantool_extern.h failed'
- Wc_c="`wc -c < 'scantool_extern.h'`"
- test 2593 -eq "$Wc_c" ||
- echo 'scantool_extern.h: original size 2593, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= sunview.c ==============
- if test -f 'sunview.c' -a X"$1" != X"-c"; then
- echo 'x - skipping sunview.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting sunview.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'sunview.c' &&
- X
- /* @(#)sunview.c 1.4 90/04/04
- X *
- X * SunView dependent graphics routines used by scantool.
- X *
- X * Copyright (c) Rich Burridge.
- X * Sun Microsystems, Australia - All rights reserved.
- X *
- X * Permission is given to distribute these sources, as long as the
- X * copyright messages are not removed, and no monies are exchanged.
- X *
- X * No responsibility is taken for any errors or inaccuracies inherent
- X * either to the comments or the code of this program, but if
- X * reported to me, then an attempt will be made to fix them.
- X */
- X
- #include <stdio.h>
- #include <sys/fcntl.h>
- #include <sys/wait.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include "scantool.h"
- #include "images.h"
- #include "scantool_extern.h"
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- X
- #define MENU_SET (void) menu_set
- #define NOTIFY_DISPATCH (void) notify_dispatch
- #define NOTIFY_INTERPOSE_DESTROY_FUNC (void) notify_interpose_destroy_func
- #define NOTIFY_INTERPOSE_EVENT_FUNC (void) notify_interpose_event_func
- #define NOTIFY_SET_WAIT3_FUNC (void) notify_set_wait3_func
- #define PR_DESTROY (void) pr_destroy
- #define PW_REPLROP (void) pw_replrop
- #define PW_ROP (void) pw_rop
- #define PW_TEXT (void) pw_text
- #define PW_TTEXT (void) pw_ttext
- #define PW_VECTOR (void) pw_vector
- #define PW_WRITEBACKGROUND (void) pw_writebackground
- #define WINDOW_READ_EVENT (void) window_read_event
- #define WINDOW_SET (void) window_set
- X
- /* Fonts used by scantool. */
- #define BOLD_FONT "/usr/lib/fonts/fixedwidthfonts/screen.b.14"
- #define NORMAL_FONT "/usr/lib/fonts/fixedwidthfonts/screen.r.14"
- X
- struct pixfont *open_font() ;
- void repaint_show_canvas() ;
- X
- Canvas canvas, show_canvas ;
- Cursor cursor[MAXCURSORS] ;
- Event *cur_event ;
- Frame base_frame, show_frame ;
- Icon scantool_icon ;
- Menu menus[MAXMENUS] ;
- Notify_value destroy(), handle_resize() ;
- Pixfont *font[MAXFONTS] ;
- Pixrect *images[MAXIMAGES] ;
- Pixrect *spr ;
- Pixwin *spw, *wpw ;
- X
- int firsttime ; /* Set if we haven't resized the window yet. */
- int init_height ; /* Initial height of the scantool window. */
- int init_width ; /* Initial width of the scantool window. */
- X
- struct rasterfile hdr ;
- X
- mpr_static(grey_pr, 16, 16, 1, grey_image) ;
- mpr_static(icon_pr, 64, 64, 1, icon_image) ;
- mpr_static(exclaim_pr, 64, 64, 1, exclaim_image) ;
- mpr_static(button_normal_pr, 64, 64, 1, button_normal_image) ;
- mpr_static(button_invert_pr, 64, 64, 1, button_invert_image) ;
- mpr_static(switch_normal_pr, 16, 16, 1, switch_normal_image) ;
- mpr_static(switch_invert_pr, 16, 16, 1, switch_invert_image) ;
- mpr_static(main_cursor_pr, 16, 16, 1, main_cursor_array) ;
- mpr_static(hour_cursor_pr, 16, 16, 1, hour_cursor_array) ;
- mpr_static(help_cursor_pr, 16, 16, 1, help_cursor_array) ;
- mpr_static(frame_cursor_pr, 16, 16, 1, frame_cursor_array) ;
- X
- X
- /*ARGSUSED*/
- void
- canvas_proc(canvas, event)
- Canvas canvas ;
- Event *event ;
- {
- X cur_event = event ;
- X handle_event() ; /* Determine what kind of event it is. */
- X process_event() ; /* And process it. */
- }
- X
- create_menu(mtype, title, values) /* Create popup menus for cycle items. */
- enum menu_type mtype ;
- char *title, *values[] ;
- {
- X int i = 0 ;
- X int more = 1 ; /* Cleared when current menu is complete.*/
- X
- X menus[(int) mtype] = menu_create(MENU_TITLE_ITEM, title,
- X MENU_FONT, font[(int) NFONT],
- X 0) ;
- X do
- X {
- X if (values[i] != NULL)
- X MENU_SET(menus[(int) mtype], MENU_STRING_ITEM, values[i], i+1, 0) ;
- X else more = 0 ;
- X i++ ;
- X }
- X while (more) ;
- }
- X
- /*ARGSUSED*/
- Notify_value
- destroy(client, status)
- Notify_client client ;
- Destroy_status status ;
- {
- X stop_scan() ; /* Stop the current scan (if there is one). */
- X exit(0) ;
- }
- X
- display_menu(menuno)
- enum menu_type menuno ;
- {
- X return((int) menu_show(menus[(int) menuno], canvas,
- X canvas_window_event(canvas, cur_event), 0)) ;
- }
- X
- draw_area(x, y, width, height, op)
- int x, y, width, height ;
- enum op_type op ;
- {
- X PW_WRITEBACKGROUND(wpw, x, y, width, height, ops[(int) op]) ;
- }
- X
- draw_image(x, y, width, height, image)
- int x, y, width, height ;
- enum image_type image ;
- {
- X PW_ROP(wpw, x, y, width, height, PIX_SRC, images[(int) image], 0, 0) ;
- }
- X
- draw_line(x1, y1, x2, y2, op)
- int x1, y1, x2, y2 ;
- enum op_type op ;
- {
- X PW_VECTOR(wpw, x1, y1, x2, y2, ops[(int) op], 1) ;
- }
- X
- draw_text(x, y, stencil, ftype, str)
- int x, y ;
- enum sten_type stencil ;
- enum font_type ftype ;
- char *str ;
- {
- X switch (stencil)
- X {
- X case STEN_OFF : PW_TEXT(wpw, x, y, PIX_SRC, font[(int) ftype], str) ;
- X break ;
- X case STEN_ON : PW_TTEXT(wpw, x, y, PIX_SET, font[(int) ftype], str) ;
- X break ;
- X case STEN_INV : PW_TTEXT(wpw, x, y, PIX_CLR, font[(int) ftype], str) ;
- X }
- }
- X
- get_event() /* Get the next SunView event. */
- {
- X WINDOW_READ_EVENT(canvas, cur_event) ;
- }
- X
- get_strwidth(ftype, str) /* Get width in pixels of string value. */
- enum font_type ftype ;
- char *str ;
- {
- X struct pr_size size ;
- X
- X size = pf_textwidth(strlen(str), font[(int) ftype], str) ;
- X return(size.x) ;
- }
- X
- grey_area(x, y, width, height)
- {
- X PW_REPLROP(wpw, x, y, width, height, PIX_SRC, &grey_pr, 0, 0) ;
- }
- X
- handle_event() /* Work out what kind of event this is. */
- {
- X curx = event_x(cur_event) ;
- X cury = event_y(cur_event) ;
- X cur_ch = event_id(cur_event) ;
- X
- X if (event_is_button(cur_event) && event_is_down(cur_event))
- X {
- X if (cur_ch == MS_LEFT) type = LEFT_DOWN ;
- X else if (cur_ch == MS_MIDDLE) type = MIDDLE_DOWN ;
- X else if (cur_ch == MS_RIGHT) type = RIGHT_DOWN ;
- X }
- X else if (event_is_button(cur_event) && event_is_up(cur_event))
- X {
- X if (cur_ch == MS_LEFT) type = LEFT_UP ;
- X else if (cur_ch == MS_MIDDLE) type = MIDDLE_UP ;
- X else if (cur_ch == MS_RIGHT) type = RIGHT_UP ;
- X }
- X else if (event_is_ascii(cur_event)) type = KEYBOARD ;
- X else if (cur_ch == LOC_MOVE) type = MOUSE_MOVE ;
- X else if (cur_ch == LOC_DRAG) type = MOUSE_DRAG ;
- X else if (cur_ch == WIN_REPAINT) type = REPAINT ;
- X else type = IGNORE ;
- }
- X
- Notify_value
- handle_resize(frame, event, arg, type)
- SHAR_EOF
- true || echo 'restore of sunview.c failed'
- fi
- echo 'End of part 4'
- echo 'File sunview.c is continued in part 5'
- echo 5 > _shar_seq_.tmp
- exit 0
-