HP SCANJET ÄÄ SCANNER CONTROL LANGUAGE Table of Contents Page OVERVIEW OF MANUAL [skipped here] 1 Purpose 1 SCANNER OVERVIEW 3 Introduction 3 SCL Commands 3 Data Path 3 Output Data Types 4 Coordinate System 5 Windows 6 Dimensional Units 7 Automatic Document Feeder (ADF) 8 HP Scanner Capabilities 9 DETAILS OF THE SCL COMMAND SET 11 Introduction 11 General Commands 12 SCL Reset Esc E 12 Scan Window Esc *f 0 S 13 ADF Scan Window Esc * u 0 S 14 Change Document Esc *u 0 X 15 Unload Document Esc * u 0 U 15 Set X Resolution Esc * a # R 15 Set Y Resolution Esc *a # S 16 Set X Scale Factor Esc *a # E 16 Set Y Scale Factor Esc *a # F 16 Set Window X Position (Decipoints) Esc * a # X 17 Set Window Y Position (Decipoints) Esc *a # Y 17 Set Window X Extent (Decipoints) Esc *a # P 17 Set Window Y Extent (Decipoints) Esc *a # 0 17 Set Window X Position (Device Pixels) Esc *f # X 17 Set Window Y Position (Device Pixels) Esc *f # Y 17 Set Window X Extent (Device Pixels) Esc *f # P 17 Set Window Y Extent (Device Pixels) Esc *f # Q 18 Select Output Data Type Esc * a #T 18 Select Data Width Esc *a # G 18 Select B/W Dither Pattern Esc *a # J 19 Select Color Dither Pattern Esc * u # J 19 Select Matrix Coefficients Esc * u # T 20 Select Tone Map Esc * u # K 20 Inverse Image Esc * a # I 20 Mirror Image Esc *a # M 21 Set Filter Esc * u # F 21 Set Intensity Level Esc * a # L 21 Set Contrast Level Esc *a # K 22 Set Automatic Background Esc *a # B 22 Position Scanner Element, Secondary Esc *f # F 22 Light Source Test Esc* f # L 22 Select Download Type Esc* a # D 22 Download Binary Data Esc*a # W (data) 23 Upload Binary Data Esc* s # U 23 Inquiry Commands 24 Inquire Present Value Esc* s # R 24 Inquire Minimum Value Esc* s # L 24 Inquire Maximum Value Esc* s # H 24 Inquire Device Parameter Esc* s # E 24 Inquire Pixels Per Scan Line Esc s 1024 E 24 Inquire Document Feeder Connected Esc*s24E 25 Inquire Document Feeder Ready Esc*s 1027 E 25 Inquire Paper in ADF bin Esc*s25E 25 Inquire ADF Open Since last Change/Scan Esc*s26E 25 Inquire Ready to Unload Esc*s27E 25 Inquire Device Pixels Per Inch Esc*s 1028 E 25 Inquire Native Optical Resolution Esc*s 1029 E 26 Inquire Bytes Per Scan Line Esc*s 1025 E 26 Inquire Number of Scan Lines Esc*s 1026 E 26 Inquire HP Model Number1 Esc*s 3 E 26 Inquire HP Model Number2 Esc*s 10 E 26 Inquire HP Model Number3 Esc* s 9 E 27 Inquire Firmware Date Code Esc* s 4 E 27 Error Reporting 28 Introduction 28 Inquire Maximum Error Stack Depth Esc*s 256 E 28 Inquire Current Error Stack Depth Esc*s 257 E 28 Read Current Error Number Esc*s 259 E 28 Read Oldest Error Esc*s 261 E 29 Error Numbers 29 Clear Errors Esc * o E 30 SCL GENERAL INFORMATlON 31 Format of Escape Sequences 31 Introduction 31 Two-Character Escape Sequences 31 Parameterized Escape Sequences 32 Format of Data Returned from the Scanners 35 Format of Inquiry Responses 3S Numerical Parameters 35 String Parameters 36 Null Response 36 Format of Scanned Data 37 Introduction 37 Format of One-Bit-Per-Pixel Data 37 Format of 16-Level B/W Grayscale Data 37 Format of 256-Level B/W Grayscale Data 38 Format of Three-Bits-Per-Pixel Data 38 Format of Chunky Color Data 38 Format of 24-bit Color Data 38 Parameter Errors 39 Pre-processing Steps 39 Exact-Value Commands 40 Range Commands 41 APPENDIX A - SCL Command Set Summary [skipped here] A-1 General Commands commands A-3 Type of Inquire A-3 APPENDIX B - Tone Map Algorithm B-1 APPENDIX C - Black and White Dither Patterns C-1 APPENDIX D - Color Dither Patterns D-1 APPENDIX E - Coefficient Matrices E-1 APPENDIX F - Hints For Using ADF Commands F-1 APPENDIX G - ASCII Character Codes [skipped here] G-1 APPENDIX H - Output Data Types and Terminology H-1 B/W Thresholded Data H-1 White Data H-1 Black Data H-1 Grayscale Data H-2 B/W Dithered Data H-2 Color Data H-3 Color Thresholded Data H-3 Chunky Thresholded Data H-4 Chunky Dithered Data H-4 Color Coefficient Matrix H-5 Image Data Transfer Curves (Tone Maps) H-6 Scaling H-7 Limitations on Scaling H-7 APPENDIX J - Scanner Driver Installation and Use J-1 Installing the Driver J-1 Using the Driver J-1 Reading Image Data From The HP ScanJet, ScanJet Plus and ScanJet IIc J-1 2. SCANNER OVERVIEW Introduction This chapter is an overview of HP scanners and contains information on their features and on the terminology used in this document. SCL Commands SCL commands are used to set individual scanner parameters. Once an SCL command sets a parameter, that parameter will keep that value until the same SCL command is repeated with a new value or the scanner is reset. Some SCL parameters can affect the valid range of other parameters - the relationship between resolution and scale is one example. Some SCL commands, while setting one parameter, have a side effect of setting another parameter. If you were to change Data Type, Data Width also changes. SCL inquiry commands can determine the valid range for the parameter and double check the parameter value. An inquiry command can determine the range by using the Inquire Model number commands; the software would then know what the range would be. You could also individually inquire the range of the parameters. The latter is more robust, for it would not require a re-write of software for a new scanner model. HP recommends using inquiry commands to avoid unexpected results. Data Path The basic image data at the sensor of the HP ScanJet and ScanJet IIp is either a 4 or 8-bit grayscale value, respectively. For the HP ScanJet IIc scanner, it is a 24-bit RGB (red, green, blue) color value. During a scan, this basic data is transformed through various stages of image processing according to the parameters set up from SCL commands prior to the scan command. The data stream is sent to the host in the desired output-data format, referred to as a data type. It is easy to set the SCL parameter using the SCL commands specified in this document. However, knowing the order of the image processing steps in the data pathof the HP ScanJet IIc scanner will help you understand how the settings of the parameters, matrices, dither patterns, and tone maps affect each other. (Setting each parameter is done independently and does not affect other parameters except as expressly indicated in the section on SCL commands.) Once a scan command is given, all the scanning parameters and selections are used in transforming data in the scanned image data path in the following order: 1. 24-bit color data scanned at 400 dpi from the scan window is sensed by the image sensor. 2. The data is then sent through the coefficient matrix which mixes the three colors according to the matrix selected resulting in a stream of modified 24-bit color data. 3. It then goes to the filter which averages 0, 2, or 4 pixels together color by color before the data stream enters the sealer stage. 4. The sealer stage adjusts the data for the desired scaling and resolution. 5. The contrast and intensity is then adjusted by using the specified tone map on each of the colors in the 24-bit data stream. 6. Output data types are created in the final stage. For black and white data Types, only one-third of the data stream which has reached this stage is used - the green data from the data stream; for color, all the data are used to create dithered, thresholded, or grayscale (and color) data types. The bits are packed in the data stream according the specificed data width (see "Format of Scan Data" section). If the inverse parameter is set, the data is inverted just before being sent to the host. NOTE The data is sensed from the image sensor oriented such that 00H is black (or dark color) and FFH is white (or light color). The orientation is reversed during the tone map stage (step 5) so that the proper orientation is sent to the host. The tone map is not affected, but downloaded matrices must take the reverse orientation into account. Output Data Types The HP ScanJet and ScanJet IIp scanners support black, white, thresholded, dithered, and grayscale output data types. The output data types supported by the HP Scan Jet IIc scanner are black, white, 8/W thresholded, B/W dithered, B/W grayscale, color, color thresholded, color dithered, chunky thresholded, and chunky dithered. For detailed information on each of these data types, refer to Appendix H. Coordinate System The coordinate system used in all SCL commands is a two-dimensional system. The coordinate system as viewed on the object being scanned is illustrated in Figure 1. Primary Scanning Direction ÄÄÄÄÄÄÄÄÄÄÄÄÄ> (Increasing X coordinate) Reference Point(0,0) \ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ ³ ³ ³ Secondary ³ ³ ³ Scanning ³ ³ Scannable Area ³ Direction ³ ³ ³ ³ ³ ³ ³ ³ ³ V ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ (Increasing Y coordinate) Figure 1. Scanner Coordinate System Scanning directions are labeled in the same order that data is transferred from the device during a scan (provided that you have not selected the image to be mirrored). The primary scanning direction indicates pixels that are adjacent on a given scan line. The secondary scanning direction is the direction the scanning bar moves in the scanner. For example, the scanner first sends data for consecutive pixels on a scan line, then the scanning bar moves down one scan line (increases the coordinate in the secondary scanning direction) and then transfers data for the next scan line. If the entire area is being scanned, the first data transferred corresponds to the data point at coordinate (0,0), which is called the reference point of the scannable area (provided that you have not selected the image to be mirrored). Windows Selecting the area to scan is done by defining a window. See Figure 2. A window is a rectangular area defined by a position and an extent in each dimension. Figure 2 illustrates a window defined by a position and an extent. (0,0)ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ Scannable Area ³ ³ ³ ³ Reference Point ³ ³ (x0,y0)ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ Window ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³ / ³ ³ (x0 + p0-1,y0 + q0-1) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Figure 2. Example of a Window x 0 = Horizontal position of window 0 y 0 = Vertical position of window 0 p 0 = Horizontal (X) extent of window 0 q 0 = Vertical (Y) extent of window 0 Dimensions supplied for the position and extent parameters should be non-negative (a negative value is interpreted as 0 and causes a parameter error). The upper-left corner of the window is called the reference point of the window. The power-on default for HP scanners is a single window with a position of (0,0), and an extent of (2550,4200) for the HP ScanJet IIc scanner and extent of (2550-3508) for the HP ScanJet and Scan Jet Plus scanners - in other words, the entire flatbed scannable area - and thresholded data type. The addition of the Automatic Document Feeder does not affect this default. Dimensional Units HP scanners support two units of dimension, the decipoint and the device pixel. There are 720 decipoints to the inch. This unit of measure is the standard for HP printers under PCL. For HP scanners, numbers to the right of the decimal point in decipoint values are valid, but they are ignored. All HP scanners, including the HP ScanJet IIc scanner, use 300 device pixels per inch for compatibility. When setting up the window to be scanned using device pixels, specify positions and extents assuming 300 device pixels per inch. NOTE The decipoint has been selected as the dimensional unit of choice to provide compatibility with future scanners that may have different numbers of device pixels per inch. The unit of measure for device pixels per inch may be inquired for any particular scanner (inquiry commands are discussed later). When decipoints are specified, the scanner converts to pixels truncating fractions. When inquiring a decipoint dimension, the scanner converts the internal pixel value to decipoints, rounding to the next higher integer value. The highest optical resolution supported by an HP scanner (the HP ScanJet IIc) in the X direction is 400 ppi, which is the resolution of the CCD that collects the raw scan data. The HP Scan Jet and ScanJet Plus optical resolution in the X direction is 300 ppi. It is important to note that the unit of measure for position and extent does not depend on the current resolution variable, and dimensions set up by those commands do not change when the scan resolution changes. For example, the position of a window that was defined when the scanner resolution was set at 300 pixels per inch does not change when the resolution is subsequently changed to 150 pixels per inch. The coordinate system is also independent of any scaling that is in effect. When a scan is requested at resolutions other than 300 ppi or scale factors other than 100, the dimensions that have been specified by the user must be converted into units of the scan data, taking resolution and scaling into account. When this occurs, dimensional calculations may result in fractional values of pixels. When this happens, the fractional value is rounded up to the next whole device pixel. For example, consider the HP ScanJet IIc scanner, which has 300 device pixels per inch, but an optical resolution of 400 ppi in the X-direction. The user will set the X and Y position using device pixels, but the actual scanned data in the X-direction will start on the next optical pixel boundary. If the user sets the scan resolution to 75 ppi and requests a scan of a window which has been defined as five device pixels wide, the scanner returns two pixels per scan line. However, the original width specification is stored in device pixels and is not affected by the rounding. Therefore, if the scan resolution is subsequently changed back to 300 ppi, a scan of the window would result in five pixels per scan line. In the case of the HP Scan Jet IIc scanner, it will always return the same number of pixels as previous scanners for identical scanner settings, but the location of the actual pixels is associated with the nearest 400th of an inch, rather than previous scanners' resolution of the nearest 300th of an inch. Automatic Document Feeder (ADF) The ADF for the HP ScanJet and ScanJet IIp scanners is a scroll-type ADF where a sheet is scrolled and scanned at the same time. The HP ScanJet IIc scanner ADF is a flatbed type allowing more flexibility in the resolution of the scan as well as allowing multiple scans to take place on a document fed by the ADF. The SCL protocol has been defined to offer as much backward compatibility as possible for applications which used SCL to operate the HP ScanJet and ScanJet IIp ADFs. New applications can choose to use the new commands to take advantage of the flatbed features, or can ignore the new features and treat the ADF the same as ScanJet IIp. The HP ScanJet IIc flatbed style ADF loads paper onto the scanner's platen prior to a scan. A load operation also causes an unload of a paper already on the platen. A scan operation, or multiple scan operations, can then take place before the next load/unload operation. An unload operation can be performed without the accompanying load, if desired. The SCL protocol to support the HP ScanJet IIc flatbed ADF is described in this document and includes the following new commands: Change Document Unload Document ADF Scan Window Inquire Paper in ADF Bin Inquire ADF Open Since Last Change/Scan Inquire Ready to Unload This document describes how the old commands, inquiries, and errors are to be interpreted to support the HP ScanJet IIc flatbed ADF. When using the new ADF commands for the HP ScanJet IIc scanner, you will need to send this set of commands - - Change Document, ADF Scan Window, and Unload Document - - instead of the old ScanJet and ScanJet Plus Scan Window command. Note that the only way a sheet on the platen of the HP ScanJet IIc scanner is ejected by the ADF into the output bin is in response to a specific command to load another sheet, or unload a sheet, or a ScanJet IIp ADF scan which loads a sheet (and automatically unloads a sheet already on the platen). No sheet is ejected at power-up, for any reset, nor due to any error or interruption. See Appendix F for hints in writing applications using the HP ScanJet IIc ADF. HP Scanner Capabilities The following chart shows the capabilities of all models of scanners made by Hewlett-Packard. Scanner Capabilities Scanner Type ScanJet ScsnJet IIp ScanJat IIc Grayscale 4 bit 4 and 8 bit 4 and 8 bit Color 3 and 24 bit Device Pixels 300 ppi 300 ppi 300 ppi Optical resolution 300 300 300 300 to 600 Automatic Document Feeder Single scan per Single scan per Multi scan pe (ADF) page page page Contrast 256 levels 256 levels Intensity 3 levels 256 levels 256 levels Download/Upload Tone Map, Tone Map, Dither Patterns Dither Pattern Coefficient Mat Filter 0, 2 and 4 bit filter Mirror Image Supported Supported Inverse Image Supported Supported Supported Auto Background Supported Supported Supported User Defined Tone Map Supported Supported B/W Dither Pattern Supported Supported* Color Dither Pattern Supported* Coefficient Matrix Supported * Supported for the HP ScanJet IIc scanner only (Y resolution) x (Y scale) > 60 ppi. 3. DETAILS OF THE SCL COMMAND SET Introduction Access to the features of HP scanners is achieved exclusively through the use of SCL commands in the form of escape sequences. The scanner treats ASCII strings that start with the escape character as a command. All unrecognized character codes and control codes are discarded by the scanner. Refer to Appendix G for the ASCII character table. Each command to set a parameter has three inquiry commands to request information on that parameter. The various inquiry commands are differentiated by the terminating character. The terminating character is set to 'L' to inquire the lowest valid value for the parameter. It is set to 'H' to inquire the highest valid value for the parameter. It is set to 'R' to request the current setting of the parameter. The scanner returns an escape sequence in response to the inquiry commands. The response escape sequence includes information as to what command the scanner is responding to and the requested value. Use of the inquiry commands is highly recommended for developing upwardly compatible scanner applications. By inquiring for the minimum and maximum values, features such as contrast and intensity, scaling, resolution, and other features of newer, more powerful SCL devices will be supported by your applications. NOTE Spaces shown in the commands are for reading clarity only and should not be part of the command. Replace the '?' of the inquiry commands with the appropriate terminating character. Replace the '#' with the appropriate ASCII characters representing the parameter setting for the command. The numbers shown in the commands must be the ASCII characters representing those numbers. That is, if the command is Esc*a257R then the command sequence is character escape (1BH), character '*'(2AH), character 'a'(61H), character '2'(32H), character '5'(35H), character '7'(37H), character 'R'(52H). The HP ScanJet IIc scanner supports SCL Commands that are a superset of previous HP scanners' command sets. Where applicable, the commands in this document that are specific to HP Scan Jet IIc scanner is noted as such. Any value fields omitted from SCL commands are interpreted as zero. General Commands SCL Reset Esc E The scanning bar is returned home, the lamp is turned off, and all SCL parameters are returned to their power-on defaults as follows: Data Type 0 (B/W Thresholded) Data Width 1 bit/pixel B/W Dither Pattern 0 (coarse fatting) Color Dither Pattern 0 (built-in) (SJ IIc only) Coefficient Matrix 2 (green only) (SJ IIc only) Tone Map 0 (contrast/intensity) (SJ lip 5 SJ IIc) Intensity 0 Contrast 0 (SJ lip 5 SJ IIc) Mirror 0 (off) (SJ lip L SJ IIc) Filter 0 (autofilter) (SJ IIc only) Auto Background 0 (off) Inverse Image 0 (off) X Resolution 300 ppi Y Resolution 300 ppi X Scale Factor 100% Y Scale Factor 100% X Location 0 Y Location 0 X Extent 2550 (device pixels) Y Extent 4200 (device pixels) (3508 for SJ 5. SJ IIp) Lamp 0 (off) Scanning bar position Home (Reported as 0) Download Type 0 (B/W dither pattern)(SJ lip 5 SJ IIc) Downloaded B/W Dither Pattern none (old pattern is erased) (SJ IIp 5 SJ IIc Downloaded Color Dither Pattern none (old pattern is erased) (SJ IIc only) Downloaded Tone Map none (old map is erased)(SJ lip 5 SJ IIc) Downloaded Matrix none (old matrix is erased) (SJ IIc only) Scan Window Esc*f0S This command causes the scanner to scan the area defined by the scan window. The value field must always be 0. A window position must be within the scannable area but may have an extent which extends beyond the scannable area. However, when the window is scanned, data is returned only for the portion of the window that lies within the scannable area. If the intersection of the window and the scannable area is null, an Illegal Window error is generated. If the requested X scale or Y scale value is outside of the valid scaIing range, the minimum or maximum valid scale factor is used and a Scaling Error is generated. If the scanning bar does not return to home position (Y = 0), the scan is aborted and a Home Position Missing Error is generated. For the HP ScanJet IIp and ScanJet IIc scanners, if a downloadable dither pattern or tone map has been selected but not downloaded, a Dither ID Error or Tone Map ID Error is generated, and the default dither pattern or tone map is used for the scan. On the ScanJet IIc, if a downloadable coefficient matrix has been selected but not downloaded, a Matrix ID Error is generated and the default coefficient matrix is used for the scan. Lamp calibration for the HP ScanJet IIp and ScanJet IIc scanners is done before each scan; if the lamp intensity is incorrect, during any portion of the scan a Lamp Error is generated. When an ADF is installed: If the ADF is not ready (as defined by the Inquire Document Feeder Ready command), a normal scan is performed assuming that the document was placed on the platen manually using the normal reference position flush against the "Document Set Mark." HP ScanJet and ScanJet IIp scanner If the document feeder is ready, then the page feeds and is scanned. HP ScanJet IIc scanner When a Scan Window command is received and the ADF is ready with paper in the paper bin, then a ScanJet Plus emulation ADF scan is performed as follows: - Paper is loaded and any paper already on the platen is unloaded by the ADF. - Any paper jam error detected during the load/unload is put on the SCL error stack as a Document Feeder Jam error. If there is a jam error, the scan is terminated and no transfer of data to the host will take place. - The paper is scanned using the reference position appropriate for the ADF (inside 2mm X-dir, 2.4mm Y-dir). - If there is no paper left in the input tray, the paper on the platen is unloaded by the ADF. If there is still paper in the input tray, no unload is done. - The unload is occurring in the background; the user does not have to wait. A paper paper jam error detected during the unload will not be reported unless it is detected on the next load/unload operation. If a paper jam is detected during the load portion of a ScanJet IIp-type ADF scan, the scan is terminated with a Document Feeder Jam error put on the SCL error stack. This is the same as the HP ScanJet and ScanJet IIp scanner. ADF Scan Window Esc * u0S (HP Scan Jet IIc scanner only) This command causes the device to scan the area defined by the scan window with the assumption that the paper was placed on the platen by the ADF. The value field must always be 0 for HP ScanJet IIc scanner. On the HP ScanJeg IIc scanner, it is assumed that the paper is placed on the platen in the ADF position thag is offset from the "Document Set Mark" (2 mm in the X-direction and 2.4 mm in the Ydirection). No load/unload operations are performed in response to this command. The ADF Scan Window command is used solely in conjunction with the Change Document and Unload Document commands. The scan operation occurs in response to the ADF Scan Window command, even if there is a Document Feeder Jam error on the SCL error stack. NOTE The HP ScanJet IIc scanner operates differently in this case. On the ScanJet IIp, a scan would not occur if a paper jam was detected; it would set a Document Feeder Jam error and 0 bytes is returned. The ADF Scan Window command for the HP ScanJet IIc scanner never generates a Document Feeder Jam error, nor clears that error (unless a new error replaces the old one). Very similar to the Scan Window command, this command causes the device to scan the area defined by the scan window. A window position must be within the scannable area but may have an extent beyond the scannable area. However, when the window is scanned, data is returned only for the portion of the window that lies within the scannable area. On the HP ScanJet IIc scanner, the scannable area is the same for an ADF scan as for a regular scan. If the intersection of the window and the scannable area is null, an Illegal Window error is generated. If the requested X scale or Y scale value is outside of the valid scaling range, the minimum or maximum valid scale factor is used and a Scaling Error is generated. If the scanning bar does not return to home position (Y = 0), the scan is aborted and a Home Position Missing Error is generated. If a downloadable dither pattern or tone map or coefficient matrix has been selected but not downloaded, a Dither ID Error or Tone Map ID Error or Matrix ID Error is generated, and the default dither pattern or tone map or coefficient matrix is used for the scan. A lamp calibration is done before each scan, and if the lamp intensity is incorrect during any portion of the scan, a Lamp Error is generated. Change Document Esc * u 0 X (HP ScanJet IIc scanner only) If the document feeder is connected, a load/unload operation is performed: paper is loaded from the input tray onto the platen at the same time any paper already on the platen is unloaded into the output tray. The document feeder does not have to be ready (as defined by the Inquire Document Feeder Ready command) to start this operation. Paper does not have to be in the input tray. If the document feeder senses a paper jam before or during the load/unload operation, the operation is aborted and a Document Feeder Jam error is generated and put on the SCL error stack. If there is no document feeder connected, a Document Feeder Jam error is generated and put on the SCL error stack. If there is no paper present in the ADF input tray, or the ADF access hatch is not closed, or the lever is not down, the unload operation only occurs and a Paper Not Loaded error is generated and put on the SCL error stack. The scanner does not respond to commands while the unload is occurring. If just an unload is desired, use the Unload Document command. If the ADF access hatch is opened, or the lever is switched to the up position after the load/unload operation has started, the operation is aborted and a Document Feeder Jam error is generated and put on the SCL error stack. Unload Document Esc * u 0 U (HP ScanJet IIc scanner only) If the document feeder is connected and the ADF is ready to unload (see the Inquire Ready to Unload command), an unload operation is performed. No paper is loaded from the input tray, but any paper on the platen is unloaded into the output tray. If there is no document feeder connected, a Document Feeder Jam error is generated and put on the SCL error stack. If the document feeder is not ready to unload, the unload operation is not started and a Document Feeder Jam error is generated and put on the SCL error stack. If the unload operation starts, a Document Feeder Jam error is not put on the SCL error stack even if one occurs. The Unload will occur in the background and the application can go on to issue other SCL commands as soon as the Unload Document command is issued. A Document Feeder Jam error is reported after the next Change Document command if it is still detected. Set X Resolution Esc * a # R This command sets the spatial resolution of the scanner data in the X or primary scanning direction. The value field is the number of pixels per inch. Valid resolutions range from 38 dpi for the HP ScanJet scanner, 12 dpi for the HP ScanJet IIp and ScanJet IIc scanners to 600 dpi for the HP ScanJet scanner, 1500 dpi for the HP ScanJet IIp scanner, and 1600 dpi for the HP ScanJet IIc scanner in steps of 1 dpi . Default X resolution is 300 dpi. This command is used to match the X resolution of the scanner to the X resolution of the printer. When this is done, a printed image is the same width as the original image when the original is scanned with 100% scaling. Set Y Resolution Esc * a # S This command sets the spatial resolution of the scanner data in the Y or secondary scanning direction. The value field is the number of pixels per inch. Valid resolutions range from 38 ppi for the HP ScanJet scanner, 12 ppi for the HP ScanJet IIp and ScanJet IIc scanners to 600 ppi for the HP ScanJet scanner, 1500 ppi for the HP ScanJet IIp scanner, and 1600 ppi for the HP ScanJet IIc scanner in steps of 1. Default Y resolution is 300 ppi. This command is used to match the Y resolution of the scanner to the Y resoiution of the printer. When this is done, a printed image is the same height as the original image when the original is scanned with 100% scaling. Set X Scale Factor Esc * a # E This command selects the scale factor in the primary scanning direction. This commarld is used for scaling the output data. The value field is the scale factor times 100, so a value of 100 (the default) means the data is unscaled. If the value field is 50 and the scanner is operating at an X resolution of 400 pixels per inch, the scanner returns 200 data samples per inch. The X scale factor in the case of the HP ScanJet IIc scanner can be from 1 to 6666 without generating an error, but the range of valid scale factors for a given scan (and the model of HP scanner) depends on the X resolution due to the following hardware constraints: 1200 < =(X Scale Factor) x (X Resolution) < =80000 (HP ScanJet IIc) 1200 < =(X Scale Factor) x (X Resolution) < =120000 (HP ScanJet IIp) 1200 < =(X Scale Factor) x (X Resolution) < =60000 (HP scanJet Plus) 3750 < =(X Scale Factor) x (X Resolution) < =60000 (HP ScanJet scanner) Note: Scaling is Data Width dependent. Therefore, the minimum and maximum X scale values should only be inquired after the X resolution has been set. If an X scale parameter is requested that is outside of the valid range but between 7 and 1758 for HP ScanJet scanner, or 1 and 5000 for HP ScanJet Plus scanner, or 1 and 6666 for HP ScanJet IIc scanner, or 1 and 10000 for the HP ScanJet IIp scanner, a Parameter Error is not generated, since it is not known before scanning starts if the resolution has changed. If an Inquire Pixels Per Scan Line or Inquire Bytes Per Scan Line or Scan Window command is attempted, it is executed using the closest allowable scale factor that does not violate the above restriction, and a Scaling Error is generated. The requested scale factor does not get modified, so that if subsequent action changes the resolution, then the requested scale can be used without re-sending the command to the scanner. Set Y Scale Factor Esc * a 4 F This command selects the scale factor in the secondary scanning direction. This command is similar to the Select X Scale Factor command. The Y scale factor in the case of the HP ScanJet IIc scanner can be from 1 to 6666 without generating an error, but the range of valid scale factors for a given scan (and the model of HP scanner) depends on the Y resolution due to the following hardware constraints: 1200 <= (Y Scale Factor) x (Y Resolution} <= 120000 (HP ScanJet IIp scanner) 1200 <= (Y Scale Factor) x (Y Resolution) <= 80000 (HP ScanJet IIc scanner) 1200 <= (Y Scale Factor) x (Y Resolution) <= 60000 (HP ScanJet Plus scanner) 3750 <= (Y Scale Factor) x (Y Resolution) <= 60000 (HP ScanJet scanner) Note: Scaling is Data Width dependent. Therefore, the minimum and maximum Y scale values should only be inquired after the Y resolution has been set. If a Y scale parameter is requested which is outside of the valid range but between 7 and 1758 for the HP ScanJet scanner, or 1 and 5000 for the HP ScanJet Plus scanner, or 1 and 6666 for the HP ScanJet IIc scanner,or 1 and 10000 for the HP ScanJet IIp scanner, a Parameter Error is not generated, since it is not known before scanning starts if the resolution has changed. If an Inquire Number of Scan Lines or Scan Window command is attempted, it is executed using the closest allowable scale factor that does not violate the above restriction, and a Scaling Error is generated. The requested scale factor is not modified, so that if subsequent action changes the resolution, then the requested scale can be used without re-sending the command to the scanner. Set Window X Position (Decipoints) Esc * a # X This command sets the distance in decipoints in the primary scanning direction from the reference point of the scannable area to the reference point of the window. The range is 0 to 6118 with a default of 0. Set Window Y Position (Decipoints) Esc * a # Y This command sets the distance in decipoints in the secondary scanning direction from the reference point of the scannable area to the reference point of the window. The range is 0 to 10078 with a default of 0. Set Window X Extent (Decipoints) Esc * a # P This command sets the width of the window in decipoints in the primary scanning dimension. The range is 3 to 6120 with a default of 6120. Set Window Y Extent (Decipoints) Esc * a # 0 This command sets the height of the window in decipoints in the secondary scanning dimension. The range is 3 to 10080 with a default of 10080 for the HP ScanJet IIc scanner and 8420 for ScanJet and ScanJet IIp. Set Window X Position (Device Pixels) Esc * f 4 X This command sets the distance in device pixels in the primary scanning direction from the reference point of the scannable area to the reference point of the window. This command is identical in operation to the similar command that uses decipoints, except for the units of the value field. The number of device pixels per inch is always 300, regardless of settings for scan resolution or scaling. The range is 0 to 2549 with a default of 0. Set Window Y Position (Device Pixels) Esc * f # Y This command sets the distance in device pixels in the secondary scanning direction from the reference point of the scannable area to the reference point of the window. This command is identical in operation to the similar command that uses decipoints, except for the units of the value field. The number of device pixels per inch is always 300, regardless of settings for scan resolution or scaling. The range is 0 to 4199 with a default of 0. Set Window X Extent (Device Pixels) Esc * f # P This command sets the width of the window in device pixels in the primary scanning dimension. The number of device pixels per inch is always 300, regardless of settings for scan resolution or scaling. The range is 1 to 2550 with a default of 2550. Set Window Y Extent (Device Pixels) Esc * f#Q This command sets the height of the window in device pixels in the secondary scanning dimension. The number of device pixels per inch is always 300, regardless of settings for scan resolution or scaling. The range is 1 to 4200 with a default of 4200 for the HP ScanJet IIc scanner and 3508 for the HP ScanJet and ScanJet IIp scanners. Select Output Data Type Esc * a#T This commard selects the type of data associated with the current window. The meaning of the parameter is as follows: 0 - B/W Thresholded 1 - White 2- Black 3 - B/W Dithered 4 - B/W Grayscale 5 - Color (24-bit) (RRRRRRRRGGGGGGGGBBBBBBBB) = 1 pixel (HP ScanJet IIc scanner only) 6 - Color Thresholded (RRRRRRRRGGGGGGGGBBBBBBBB) = 8 pixels (HP ScanJet IIc scanner only) 7 - Color Dithered (RRRRRRRRGGGGGGGGBBBBBBBB) = 8 pixels (HP ScanJet IIc scanner only) 8 - Chunky Thresholded (ORGBORGB) = 2 pixels (HP ScanJet IIc scanner only) 9 - Chunky Dithered (ORGBORGB) = 2 pixels (HP ScanJet IIc scanner only) The default is 0 (B/W Thresholded). Select Data Width Esc * a#G (HP ScanJet IIp and ScanJet IIc scanners only) This commard selects the format in which data is sent to the host. For black and white data types, a parameter value of 8 sends the data in one 8-bit pixel per byte, a parameter value of 4 sends the data in two 4-bit pixels per byte, and a parameter value of 1 sends the data as 8 one-bit pixels per byte. For the HP ScanJet IIc scanner, the widths for the various color data types are: 3-bits/pixels, 4-bits/pixel, and 24-bits/pixel. See the section on "Format of Scanned Data" for information of how the data is packed. Each time a data type is selected, the data width parameter is reset to the default data width for that data type. Note: Scaling is Data Width dependent. Select B/W Dither Pattern Esc * a # J This command selects the B/W dither pattern to be used for dithered data. Dither patterns are either fixed values stored in ROM or downloadable values. Each dither pattern has an associated ID number. ID numbers for fixed patterns are non-negative, numbered from 0 up while downloaded dither IDs are negative numbers from -1 down. HP ScanJet IIc scanner and ScanJet Plus supports 1 downloadable B/W dither patterns with an ID of -1. The default B/W dither pattern ID is zero. If a B/W dither pattern of -1 is selected but no pattern downloaded for that ID, then a Dither ID Error is generated if a B/W dithered scan is requested, and pattern 0 is used. The B/W dither patterns are: Pattern -1: User Defined (HP ScanJet IIp and ScanJet IIc scanner only) Pattern 0: Coarse Fatting Pattern 1: Fine Fatting Pattern 2: Bayer Dither Pattern 3: Vertical Line Patterns 0 - 3 are optimized for Laser Jet series II printers. See Appendix C for more information about the internal B/W dither patterns for the HP Scan Jet IIc and ScanJet IIp scanners. Select Color Dither Pattern Esc * u # J (HP ScanJet IIc scanner only) This command selects the color dither pattern to be used for dithered data. Dither patterns are either fixed values stored in ROM or downloadable values. Each dither pattern has an associated ID number. ID numbers for fixed patterns are non-negative, numbered from 0 up, while dowoloaded dither IDs are negative numbers from -1 down. The HP ScanJet IIc scanner supports 1 downloadable color dither pattern with an ID of -1. The default color dither pattern ID is zero. If color dither pattern -1 is selected but no color dither pattern downloaded, then a Dither ID Error is generated if a color dithered scan is requested, and color dither pattern 0 is used. The HP ScanJet IIc scanner color dither patterns are: Pattern -1: User-Defined Pattern 0: Coarse Fatting See Appendix D for more information about the internal color dither pattern. Select Matrix Coefficients Esc * u # T (HP ScanJet IIc scanner only) This command selects which coefficient matrix is to be used for the scan. If none is explicitly selected after choosing a data type, the default matrix for that data type is used. If a matrix other than the default is desired, it must be selected after the data type is selected. There are five built-in matrices and one user-defined (downloadable) matrix with identifications as follows: -1: User Defined (downloadable) 0: Red, Green, Blue NTSC * (default for all color data types) 1: Black and White NTSC * (default for B/W Dithered L B/W grayscale) 2: All three colors pass through (default for B/W Thresholded) 3: Red appears on all three channels 4: Blue appears on all three channels * National Television Standard Committee. The pass through matrix (ID 2) causes the matrixing function to be bypassed. When the data type is one of the black and white types, pass through will appear as green only. See Appendix E for the actual matrix coefficients and examples for downloading. Select Tone Map Esc * u # K (HP ScanJet IIp and ScanJet IIc scanners) This command selects the grayscale transfer-curve look-up table to be used for the next scan. A -1 selects the downloaded tone map, and a 0 selects the tone map defined by the contrast and intensity parameters. If tone map -1 is selected but no pattern downloaded, then a Tone Map ID Error is generated if a scan is requested, and tone map 0 is used. Inverse Image Esc * a#I This command inverts the polarity of the data returned from scanner. A parameter value of 0 is the default. 0 = white and 1 = black for B/W Thresholded and 8/W Dithered data types; 0 = white and 15 = black for 16 level 8/W Grayscale; 0 = white and 255 = black for 256 level B/W Grayscale; (HP Scan Jet IIp and Scan Jet IIc scanners only) 0 = bright and 1 = colored for each color of the color thresholded and color dithered types; (HP ScanJet IIc scanner only) 0 = bright and 255 dark color for each color for 24 bit/pixel color). (HP ScanJet IIc scanner only) A parameter value of 1 causes the data to be inverted. 0 = black and 1 = white for B/W Thresholded and B/W Dithered data types; 0 = black and 15 = white for 16 level B/W Grayscale; 0 = black and 255 = white for 256 level B/W Grayscale; (HP ScanJet IIp and ScanJet IIc scanners Only) 0 = colored and 1 = bright (fully saturated) for each color of the color thresholded and color dithered types;(HP ScanJet IIc scanner only) 0 = dark color & 255 = bright (fully saturated) for each color for 24 bit/pixel color (HP Scan Jet IIc scanner only) Data inversion applies to all the HP ScanJet IIp and HP ScanJet IIc scanner data types. The default setting is OFF. Mirror Image Esc * a # M (HP ScanJet IIp and ScanJet IIc scanners) This commad turns the mirror image feature on or off. When mirror image is on, the order of the data is reversed in the primary scanning direction. A 0 in the value field turns the feature off; a value of 1 turns it on. Default is off. Pad bits, if needed, appear at the end of the data stream. Set Filter Esc * u # F (HP ScanJet IIc scanner only) The HP ScanJet IIc scanner has the ability to smooth image data to reduce interference patterns when scaling down. This is done by averaging pixels in the X direction. Four options are available using the Set Filter command: 0: auto-filter (default) 1: 2-pixel averaging 2: 4-pixel averaging 3: off always Option 0, auto-filter, will cause the scanner to pick the best type of filtering for a scan, depending on the current scaling and resolution parameters. There is no way for an application to inquire which filtering is used for a scan when auto-filter is chosen. The application can, however, choose which filter it wants by using one of the other three options. Set Intensity Level Esc * a #' L This command controls the lightness or darkness of the scanned image. The value field for the HP ScanJet scanner can range from -1 to +1, with 3 intensity levels Normal, Brighter, and Darker. The value field for HP ScanJet IIp and ScanJet IIc scanner can range from 127 to + 127, for a total of 255 intensity levels. The default intensity level is 0(Normal). A positive value results in a lighter image, and a negative value results in a darker image. For the HP ScanJet IIp and ScanJet IIc scanner, dithered and grayscale data types are affected when tone map 0 is used. For the HP ScanJet IIc scanner, color is also affected when tone map is 0. Thresholded data is also affected when auto background is off and tone map 0 is used. See appendix H for more information on thresholded data. Set Contrast Level Esc * a # K (HP ScanJet IIp and ScanJet IIc scanners) This command controls the difference between light and dark in ghe scanned image. The value field can range from -127 to + 127, for a total of 255 contrast levels. The default contrast level is 0(normal). A positive value results in a larger difference, and a negative value results in a smaller difference. This command affects dithered and grayscale data types when tone map 0 is used. Set Automatic Background Esc * a # B This command turns the automatic background control feature on or off. Automatic background control is used to adjust the threshold automatically for B/W Thresholded data. A 0 turns it off, and a 1 turns it on. The default is off. This command only works with B/W Thresholded data, and has no effect on other data types. The contrast and intensity parameters have no effect when automatic background control is in use. Position Scanner Element, Secondary Esc * f 4 F When the scanner receives this escape sequence, the scanning element is moved to the position specified in the value field in the secondary scanning dimension. The value field is a dimension in pixels (300 dpi). The default setting is 0. Note that even though home position is not the same as Y = 0, an inquiry with the scanning bar in either position is reported as 0. Light Source Test Esc * f # L This command turns the scanner light on and off. A value of 0 turns off the light, and a value of 1 turns it on. When the light has been on for three to five minutes in the HP ScanJet IIc scanner, or 20 seconds for the HP ScanJet and ScanJet IIp, the scanner will automatically turn the light off. The default setting is OFF. Select Download Type Esc * a # D (HP ScanJet IIp and ScanJet IIc scanners) The value field specifies what kind of download is about to be executed. The values supported by HP ScanJet IIp and ScanJet IIc scanners are as follows: Value Data to Download Bytes to Download Data Format 0 B/W Dither Pattern 64 8x8 by row 1 Tone Map 256 0,1,2..255 2 Matrix Coefficients 9 r>>r, r>>g,... (SJ IIc only) 3 Color Dither Pattern 192 8x8r, 8x8g, Sx8b (SJ lie only) Download Binary Data Esc * a 4 W (data) (HP ScanJet IIp and Scan Jet IIc scanners) This is the generic command to send binary data to a scanner, with the parameter specifying how many bytes of data follow. The number of bytes expected is specified by the Select Download Type command. If the number of bytes sent is different than the number expected, a Parmeter Error occurs. If any group character other than "a" is received, an Unrecognized Command Error is generated. In any event, whenever the escape sequence with a "W" is received, the sequence is continued until the terminating character is received and the next "#" characters are treated as binary data - being used appropriately if it is a valid command and being thrown away if it is an invalid command. Upload Binary Data Esc * s # U (HP ScanJet IIp and ScanJet IIc scanners) This command requests that the currently selected B/W dither pattern (# = 0), or currently selected downloaded tone map (# = 1) be uploaded to the host. In the case of the HP ScanJet IIc scanner, the currently selected coefficient matrix (# = 2), or currently selected color dither pattern (# = 3) can also be uploaded to the host. If the requested data hasn't been downloaded yet, or if a value greater than 1 for the HP ScanJet IIp scanner, or 3 for the HP ScanJet IIc scanner, or less than 0 for either is specified, then a null response is returned. The data is uploaded in the following formats, where the "#" is the requested parameter number and {data) is the data being uploaded: B/W Dither Response: Esc * s0t64 W (data) Tone Map Response: Esc*s 1 t 2 5 6 W (data) Matrix Coef. Response: Esc*s 2 t 9 W (data) (HP Scan Jet IIc scanner only) Color Dither Response: Esc*s 3 t 1 9 2 W (data)(HP ScanJet IIc scanner only) Null Response: Esc*s # t N Inquiry Commands See the section "Inquiry Commands" of Appendix A for a summary of the Inquire and Response formats. Inquire Present Value Esc*s # R This command is used to read back the present values of parameters that can be set wgh various SCL commands. An inquiry number is placed in the value field to identify which parameter is being requested. The inquiry number for a given parameter is a function of the characters in the command used to set the parameter. The formula is as follows: Inquiry Number = (P-"!" +1)*1024 + (G-"'"+1)*32 + (7-"@"+1) where the escape sequence to set the parameter is of the form Esc P G # T. A list of the inquiry numbers for all parameters is in Appendix A, under "General Command Summary." If the value field of an Inquiry command is not recognized, a null response is returned, but no error is generated. If the host sends the scanner any command after an Inquiry command before reading the response to the inquiry, the response is lost. Inquire Minimum Value Esc*s # L This command is identical to the Inquire Present Value command except that the minimum allowable value for the specified parameter is returned. If the parameter is a scale factor, the minimum allowable value is calculated based on the current settings of the associated SCL parameters. Inquire Maximum Value Esc*s # H This command is identical to the Inquire Present Value command except that the maximum allowable value for the specified parameter is returned. If the parameter is a scale factor, the maximum allowable value is calculated based on the current settings of the associated SCL parameters. Inquire Device Parameter Esc*s # E This command is used to determine characteristics of the scanner or of the current window. The value field defines the characteristic being inquired. Appendix A provides a summary of the device parameter inquiries and responses. Inquire Pixels Per Scan Line Esc * s 1024 E This command can be used to determine the number of pixels per scan line that is returned if a scan is requested. The number of pixels per scan line is a function of the scan resolution, the X scale factor, and the portion of the X extent which lies within the scannable area. If the X scale factor is outside of the valid range, the minimum or maximum X scale value is used and a Scaling Error is generated. Inquire Document Feeder Connected Esc*s24E In this inquiry a 1 is returned if an Automatic Document Feeder is connected to the scanner; otherwise, a 0 is returned. A 0 may also be returned if the scanner firmware cannot talk reliably to the ADF firmware. It is advantageous to use this inquiry before trying to use any other ADF inquiries or commands; if the ADF is not connected, this inquiry will respond the fastest. Other inquiries and commands will use longer timeouts when trying to talk to the ADF because they assume the ADF is connected. Inquire Document Feeder Ready Esc * s 1027 E This escape sequence can be used to determine if the Automatic Document Feeder is ready to paper feed. If a 0 is returned, the ADF is not ready to load paper. A 1 is returned only if all the following conditions are true: The ADF unit is connected. Paper is present in the ADF input tray. The ADF access hatch is closed. The ADF is in the down position. The ADF does not currently sense a paper jam. The ADF lever is down (HP ScanJet IIc scanner only). Inquire Paper in ADF Bin Esc * s 25 E (HP Scan Jet IIc scanner only) This inquiry returns a 1 if there is paper currently detected in the input tray, and a 0 otherwise. Inquire ADF Open Since Last Change/Scan Esc *s26E (HP ScanJet IIc scanner only) This inquiry returns a 1 if the ADF was detected in the up position at any time since the last ADF Scan Window, Scan Window, or Change Document command completed, and a 0 otherwise. Note that this command is valid even if the ADF is not used to load the paper. Inquire Ready to Unload Esc *s27E (HP ScanJet IIc scanner only) This escape sequence can be used to determine if the Automatic Document Feeder is ready to do an unload operation. If a 0 is returned, the ADF is not ready to unload the paper currently on the platen. A 1 is returned only if all the following conditions are true: * The ADF unit is connected. * The ADF is in the down position. * The ADF does not currently sense a paper jam. Inquire Device Pixels Per Inch Esc * s 1028 E The HP ScanJet, ScanJet IIp, and ScanJet IIc scanners always return a value of 300 in response to this escape sequence. Inquire Native Optical Resolution Esc * s 1029 E (HP ScanJet IIc scanner only) The HP ScanJet IIc scanner always returns a value of 400 in response to this escape sequence. This command is used for descriptive purposes only, and the value returned does not relate to any other commands. Inquire Bytes Per Scan Line Esc * s 1025 E This command determines the number of bytes per scan line that is returned if a scan is requested. A scan line always ends on a byte boundary and, sometimes, in the case of the HP Scan Jet IIc scanner on a three-byte boundary. Therefore, it is possible that the last byte (or last three bytes) includes some padding bits. The number of bytes per scan line is a function of the scan resolution, the X scale factor, the portion of the X-extent which lies within the scannable area, the number of bits per pixel, and the format of the data stream. If the X scale factor is outside of the valid range, the minimum or maximum X scale value is used and a Scaling Error is generated. Inquire Number of Scan Lines Esc * s 1026 E This command determines the number of scan lines that is returned if a scan is requested. The number of scan lines is a function of the scan resolution, the Y scale factor, and the portion of the Y-extent which lies within the scannable area. If the Y scale factor is outside of the valid range, the minimum or maximum Y scale value is used and a Scaling Error is generated. The total number of bytes transmitted for a scan can be determined by requesting the number of bytes per scan line and the number of scan lines, then multiplying the two numbers. Inquire HP Model Number 1 Esc * s 3 E The following escape sequences for all the HP scanners: HP ScanJet scanner Esc*s3d5W9190A HP ScanJet Plus scanner Esc*s3d5W9195A HP Scan Jet IIc scanner Esc*s3d5W9195A HP Scan Jet IIp scanner Esc*s3d5W9195A Inquire HP Model Number 2 Esc *s10E (HP ScanJet IIc scanner only) The following escape sequeneces for all the HP scanners: HP ScanJet scanner Esc* s 1 0 d N HP Scan Jet Plus scanner Esc* s 1 0 d N HP ScanJet IIp scanner Esc* s 1 0 d N HP Scan Jet IIc scanner Esc* s 1 0 d 5 W 1 7 5 0 A Inquire HP Model Number 3 Esc * s 9 E The following escape sequeneces for all the HP scanners: HP ScanJet scanner Esc * s 9 d N HP Scan Jet Plus scanner Esc * s 9 d N HP Scan Jet IIc scanner Esc * s 9 d N HP ScanJet IIp scanner Esc * s 9 d 5 W 1 7 9 0 A NOTE The HP ScanJet IIc scanner responds to two model number commands, HP Model Number1 and HP Model Number2, meaning it has some support for the command set each model number represents. For HP Model Number1, HP ScanJet IIc scanner always returns 9195A. For HP Model Number2, HP ScanJet IIc scanner always returns 1750A. The HP ScanJet IIp scanner responds to two model number commands, HP Model Numberi and HP Model Number3, meaning it has some support for the command set each model number represents. For HP Model Number1, HP ScanJet IIp scanner always returns 9195A. For HP Model Number3, HP ScanJet IIp scanner always returns 1790A. Inquire Firmware Date Code Esc * s 4 E This escape sequence causes the scanner to return a 4-digit number which is the firmware date code. The HP convention for date codes is that the two left digits are the years since 1960 and the two right digits are the week of the year, starting with 01 for the first week of the year. For example, the week beginning with January 6, 1986 would be represented as 2602. ERROR REPORTING Introduction When an error condition is detected by an SCL device, an integer error number is generate and pushed onto a last-in-first-out error stack which can be read by the host. HP scanners hold only the most recent error number in the error stack. One can read the most recent error and the oldest error since the last Reset or Clear errors command. The data items maintained by HP scanners include the following: Error Stack Error number of the most recent error. The HP ScanJet, ScanJet IIp and ScanJet IIc scanners support only one position in the stack. Oldest Error Report The error number of the earliest error to occur since the last time there was a reset or the errors were cleared. This number may also be recorded in the error stack, but can be read without affecting the Current Error Stack Depth. This item is cleared only with Reset or Clear Errors SCL commands, or, in the case of the HP ScanJet IIc scanner, a SCSI Reset. Current Stack Depth This is 1 if an error is recorded in the stack, or 0 if no error has occurred since the last Reset or Clear Errors commands, or, in the case of the MP ScanJet IIc scanner, a SCSI Reset. The following steps are taken when an error is detected: 1. An error number is generated. 2. If the Current Stack Depth has a value of 0, the new error number is recorded as thi Oldest Error Report. 3. The new error number is entered on the error stack, replacing any error which may l there, and the Current Stack Depth is set to 1. 4. The error bit on the Centronics interface is set to true. (HP ScanJet and ScanJet IIp scanners only) The following sections describe the commands for manipulating and reading the data items. See Appendix A for a summary of commands and responses. Inquire Maximum Error Stack Depth Esc * s256E This command causes the scanner to return a value of 1. Inquire Current Error Stack Depth Esc * s 257 E When the scanner receives this command, it returns a 1 if an error has occurred since the last Reset or Clear Errors command, or in the case of HP ScanJet IIc scanner, a SCSI Rese Otherwise, a 0 is returned. Read Current Error Number Esc * s 259 E This command causes the device to return the error number of the current error. Use of tt command does not cause the error to be cleared. If the Current Stack Depth is 0 (i.e., thei have been no errors since the last Reset or Clear Errors command, or SCSI Reset), the null response is returned (Esc s259dN). The Current Error Number can be cleared with Reset or Clear Errors command, or, in the case of the HP ScanJet IIc scanner, a SCSI Reset. Read Oldest Error Esc *s261E This command causes the device to return the Oldest Error Number. Use of this command does not cause the error to be cleared. The Oldest Error Number is cleared with Reset or Clear Errors commands, or, in the case of the HP ScanJet IIc scanner, a SCSI Reset. If there has been no error since the last time errors were cleared, the device returns a null response (Esc*s261dN). Error Numbers The following errors can be reported. Error Number Meaning Command Format Error 0 Escape sequence has illegal format. Unrecognized Command 1 Escape sequence has proper format, but function not supported by HP ScanJet, ScanJet IIp or ScanJet IIc scanners. (See Note 1 next page) Parameter Error 2 Parameter value out of legal bounds. illegal Window 3 Window and scannable area do not intersect. Scaling Error 4 Scale factor out of bounds. Dither ID Error 5 A downloadable dither pattern was (SJ IIp 5 SJ IIc) selected but not downloaded before requesting a dithered scan. Tone Map ID Error 6 A downloadable tone map was selected (SJ IIp 5 SJ IIc) but not downloaded before requesting a scan. Lamp Error The lamp did not achieve the required (SJ IIp 5 SJ IIc) intensity for proper scanning. Matrix ID Error 8 A downloadable coefficient matrix was (SJ lie only) selected but not downloaded before requesting a scan. Document Feeder Jam 1024 Paper jam in the document feeder (see note 2 below). Home Position Missing 1025 Scanner element failed to return to home position. Paper Not Loaded 1026 Change document was executed, but no (SJ IIc only) paper was in the ADF input bin. Note 1: (HP ScanJet or ScanJet IIp Scanners) If the host turns around the communication line before a terminating character has been received by the scanner, the scanner terminates the escape sequence at that point and proceeds with error generation and command parsing just as if an escape character had been received. The only difference is that when the line turns around again, the state machine is at TOP with line turnaround, while it is at PARAMIZ with an escape character. There should always be an illegal command error generated if the line turns around before the terminating character is received. During parsing and execution, other errors may also be generated as described above. Note 2: Document Feeder Jam (HP ScanJet IIc Scanner) A Document Feeder Jam is Dut on the SCL error stack if, during a load/unload operation caused by a Change Document command or a HP ScanJet/ScanJet Plus scanner type ADF scan due to a Scan Window command, a paper jam is detected (see "Change Document" command for details of what causes a paper jam condition). An Unload Document command can only cause a Document Feeder Jam error to be put on the SCL error stack if an error condition existed before the unload operation started. An ADF Scan Window command can never cause a Document Feeder Jam error. A Document Feeder Jam error on the SCL stack can only be cleared by the application sending a Clear Errors or SCL Reset command. The SCL Reset will unconditionally clear out the Document Feeder Jam error. The Clear Errors command will also clear the error even if a "state" paper jam still exists (This is different than the HP ScanJet and ScanJet Plus scanners). Clear Errors Esc * o E This command causes the following actions: 1. Clears the error stack. 2. Resets Current Stack Depth to zero. 3. Clears Oldest Error Number. 4. SCL GENERAL INFORMATION Format of Escape Sequences Introduction This chapter describes the generalized format of the escape sequences used by HP scanners. Two-Character Escape Sequences General Form Two-character escape sequences take the form Esc X, where X is a character from the ASCII table within the range 30H through 7EH (0 through ~). If a character within the range 21H through 2FH (! through /) is received, the escape sequence is parameterized and should be interpreted as discussed below in "Parameterized Escape Sequences." Illegal Syntax If a character within the range 0H through 20H (NUL through SPACE), 7FH (DEL) or 80H through FFH is received (after an escape), the sequence is illegal and should generate a command format error. The illegal character should then be processed at the Top level of escape sequence parsing. The Top level of escape sequence parsing is that level at which the character is treated as a printable character or a control code (i.e., independent of the preceding characters). Unrecognized Two-Character Escape Sequences For the HP ScanJet and ScanJet IIp scanners, the only supported two-character escape sequence is Esc E. Therefore, if any character from 30H to 7EH other than 45H (E) follows the Esc character, an Unrecognized Command Error is generated. Parameterized Escape Sequences General Form Parameterized escape sequences have the form: Esc X y # zi # z2 # z3 ... # Zn(Data) where y, #, zi and (Data) are optional. X Parameterized Character - A character from the ASCII table within the range 21H through 2FH (! through /). The purpose of this character is to indicate that this escape sequence is parameterized. The only parameterized character valid for HP scanners is '*" (2AH). y Group Character - A character from the ASCII table within the range 60H through 7EH (' through -). The purpose of this is to specify the group or type of control being performed. The group character is optional. If the group character is not present, it specifies a unique group of functions. # Value Field - A group of characters specifying a numeric value. This field can contain any characters within the range 20H through 3FH (Space through ?). zi Parameter Character - Any character from the ASCII table within the range 60H through 7E (' through ~). This character specifies the parameter to which the previous value field applies. The parameter character may optionally be replaced by its related upshifted character, signifying the termination of the escape sequence. Zn Terminating Character - Any character from the ASCII table within the range 40H through 5E (@ through "). This character speciTies the parameter to which the previous value field applies. This character terminates the escape sequence and can be used in lieu of zi. (Data) Refers to binary data.- Binary data is 8-bit data associated with an escape sequence that is not interpreted by escape sequence parsing. Binary data must immediately follow the terminating character. Value Field A value field contains a numeric value. A numeric value is represented as an ASCII string of digits (i.e., "0" through "9") which may be preceded by a unary sign (i.e., "+" or "-") and succeeded by a fractional portion via use of the decimal point ("."). Value fields are assumed to be integer, unless otherwise specified in the escape sequence definition. If the numeric value field is not present and one is expected, a value of 0 is assumed. The base of the numeric value field is decimal. Leading zeros and blanks are ignored. The magnitude of the value field should be no larger than 32767. If a value larger than 32767 is specified, the associated parameter should be set to the limit (i.e., 32767 for unsigned or positive numbers and -32767 for negative numbers). A plus "+" or a minus "-" sign terminates the previous numeric value field, if any, and begins a new numeric value field. Spaces are ignored until the numeric value field starts. The decimal digits "0" through "9" and "." start a numeric value field. Once a numeric value field has started, spaces act as a terminator, closing out the numeric value field. Once a numeric value field is started, anything other than a "0" through "9" or the first occurrence of a decimal point "." closes out the value field. A decimal point "." indicates the start of a fractional portion. Once processing of a fractional portion begins, another decimal point terminates the numeric value field. If more than one value field is received and only one is expected, a Parameter Error is generated. Terminating Character The terminating character (Zn) is actually the parameter character of the last parameter in the command sequence. However, to distinguish Zn from the preceding parameter characters (zi), the last zi is changed to Zn by subtracting 32 from its ASCII value. If zi is an alphabetic character, this changes zi from lower case to upper case. For example, 'Esc*f1L' and "Esc*f1l300P both turn on the scanner lamp, but the second command also positions the scanner element. Furthermore, some group characters (y) may not be followed by any parameters. In this case, the group character (y) becomes the terminator by subtracting 32 from its ASCII value (i.e., y becomes Zn). However, no commands of this type are supported by the scanner. Execution The functions being performed should be executed as they are decoded. There may be instances in which the order of the parameters may be significant. Binary Data Transfers One of the uses of parameterized escape sequences is for the transfer of binary data to the scanner. To ensure that future and past products that do not support features requiring binary data transfer are still able to interpret this data in a nondisruptive fashion, a general guideline is required. The transfer of binary data within any parameterized escape sequence should use a value field to describe the number of bytes to be transferred and a parameter of "w/W'. The terminator "Zn" should be followed immediately by the binary data. Only one parameter specifying binary data in an escape sequence is supported. If more than one parameter specifying binary data is sent, the first parameter is effective. The binary data for the other parameters is treated as normal user data and commands. Please note that not all binary transfer escape sequences are defined by the "w/W' parameter. However, this is the preferred parameter for standardization. The format would appear as: Esc X y # w ... Zn (binary data) where the binary data string contains "#" bytes. Stripping of illegal or unsupported escape sequences should also discard the binary data associated with the sequence. Unsupported binary escape sequences, denoted by the "w/W" parameter, should be handled as an unrecognized command and the binary data stripped. The "w/W" parameter always implies binary data. Illegal Syntax If an illegal character is received within an escape sequence (i.e., the syntax is incorrect), the processing of that escape sequence should terminate, and a command format error should be generated. The illegal character should be interpreted independently of the previous characters for data preservation (e.g., processed at the Top level, independent of preceding characters). Note Illegal syntax applies only to the user data. The device should interpret and ignore all data added to the user's data stream for protocol purposes (e.g., 'ENQ' for serial ENQ/ACK protocol). Unrecognized Parameterized Escape Sequences Any parameterized escape sequence (or portion thereof) that is syntactically correct but not recognized is ignored, and an unrecognized command error is generated. Parameterized Escape Sequences with Invalid Parameters Any recognized parameterized escape sequence this contains an illegal parameter value generates a parameter error. However, the requested parameter is not ignored. The scanner attempts to select a supported parameter that is "close" to the one requested. FORMAT OF DATA RETURNED FROM THE SCANNERS Format of Inquiry Responses Responses to inquiries for status are in the form of PCL/SCL escape sequences. Specific status responses supported are summarized in the section on Inquiry Commands in Chapter 3. Numerical Parameters The general form of responses to inquiries for numerical values is as follows: Esc s < inquiry ID > < terminator 1 > < value > V < inquiry ID >: The value field of the corresponding inquiry. There is a unique ID assigned to every parameter that can be inquired. < terminator 1 >: "p" - for responses to inquiries of the form Esc * s 4 R. "d" - for responses to inquiries of the form Esc * s 4 E. "k" - for responses to inquiries of the form Esc * s # L. "t" - for responses to inquiries of the form Esc * s 4 U. (HP ScanJet IIp and Scan Jet IIc scanners) < value >: The realized value of the parameter. In the case of parameters that can be set directly with SCL escape sequences, the value is in the same units as the value field used to set the parameter. The fact that this is a "realized" value means that any rounding or clipping (in the case of dimensions) done by the scanner should be reflected in the value returned. Returned decipoint values is rounded up to the next higher integer value to compensate for the truncation that occurs within the scanner when decipoint values are received that do not exactly translate to an integral number of device pixels. String Parameters The general form of responses to inquiries for string values is as follows: Esc*s d W < inquiry ID >: The value field of the corresponding inquiry. There is a unique ID number assigned to every parameter that can be read. < byte count >: A value that is the number of bytes of string data that follows the terminator character. : The string parameter that was requested by the inquiry. Null Response The scanner will return a response for any status inquiry that is received from the host. An inquiry is any escape sequence of the format: Esc*s# < terminator >. If the scanner receives an inquiry for a parameter that is not supported, then it will return a null response, but no error is generated. The format of the null response is as follows: Esc*s N FORMAT OF SCANNED DATA Introduction Scanned data is returned as a single block of binary data without header or trailer information. Since a read of scanner data typically involves the transfer of a large amount of data at a relatively high rate, it is important not to constrain the host to parse the data as it is read. Therefore, the SCL standard for unencoded data transfers is that the data does not include control embedded in the data. All scan lines in a given scan contain the same number of bytes and represent the same number of pixels. Format of One-Bit-Per-Pixel Data One-bit-per-pixel data includes the output data types of B/W Thresholded, B/W dithered, black, and white data. The first pixel of data for each scan line begins with the most significant bit of the first byte of data for that scan line, with the adjacent pixel being represented by the next most significant bit, and so forth. Each byte represents data for eight pixels, except the last byte of the scan line, which is padded if necessary to complete the transfer of the scan line in an integral number of bytes. In most cases, padding bits are image datas. Format of 16-Level B/W Grayscale Data The scanner outputs 16-level B/W grayscale data as two 4-bit pixels per byte. The most significant bit of the first data byte returned to the host is the most significant bit of the grayscale value of the first pixel on the scan line. The Most Significant Bit (MSB) of each grayscale value is adjacent to the Least Significant Bit (LSB) of the previous pixel. As with one-bit-per-pixel data, the last byte is padded with image data, if necessary, to achieve an integral number of bytes for the scan line. Format of 256-Level B/W Grayscale Data (HP ScanJet IIp and ScanJet IIc scanner) The HP ScanJet IIc and ScanJet IIp scanners output 256-level grayscale data as one 8-bit pixel per byte. The most significant bit of the first data byte returned to the host is the most significant bit of the grayscale value of the first pixel on the scan line. The next pixel is contained in the next byte to the end of the line. No padding is necessary to achieve an integral number of bytes for the scan line. Format of Three-Bits-Per-Pixel Data (HP Scan Jet IIc scanner only) Three-bits-per-pixel data includes Color Thresholded and Color Dithered output data types. For each pixel, three bits are generated, representing red, green, and blue, respectively. The bits are packed so that three bytes represent eight pixels with the first byte containing 8 pixels' red values, followed by a byte of those 8 pixels' green values, followed by a byte of those 8 pixels' blue values. The last three bytes of a line may each be padded with image data to make the data stream end on a three-byte boundary. Format of Chunky Color Data (HP ScanJet IIc scanner only) Data for the chunky data types, Chunky Dithered and Chunky Thresholded, is formatted as 3-bits-per-pixel with one bit each representing red, green, and blue values for that pixel. The bits are packed as two pixels per byte in the form ORGBORGB as eight-bits for two pixels. The first bit for each chunk is always zero, followed by the thresholded values for red, green, and blue for that pixel. The last byte of a line may contain information for a pixel beyond the actual scanning window to make the data stream end on a byte boundary. Format of 24-bit Color Data (HP ScanJet IIc scanner only) The HP ScanJet IIc scanner outputs 24-bit color as 8-bits of red, followed by 8-bits of green, followed by 8-bits of blue so each pixel is represented by 256-levels of each of the three primary colors. The most significant bit of the first data byte returned to the host is the most significant bit of the red value of the first pixel on the scan line. The green value of the first pixel is contained in the next byte, and the blue value is contained in the next byte. The fourth byte contains the red value of the second pixel and so on to the end of the line. No padding is necessary to achieve an integral number of bytes for the scan line. PARAMETER ERRORS This section describes the conditions that will cause a parameterized escape sequence to generate a parameter error. Pre-processing Steps When a recognized parameterized command is received by the scanner, the parameter value is pre-processed according to the following steps: 1. If no value is specified, a value of 0 is assumed. 2. Negative values are truncated to negative integers. 3. Positive values are truncated to positive integers. 4. If the value is less than -32767, it is changed to -32767. 5. If the value is greater than 32767, it is changed to 32767. The following table illustrates these steps and shows which values will cause a parameter error. Step Requested Value Modified Value Parameter Error 1 none 0 no 2 -abc.xyz -abc no 3 abc.xyz abc no 4 <-32767 -32767 yes 5 >32767 32767 yes Exact-Value Commands Exact-value commands will generate a parameter error if the modified value from the preprocessing steps does not exactly match a supported value. The supported values for these commands are as follows: Supported Values Exact Value Command ScanJet ScanJet IIp ScanJet IIc Select Output Data Type 0,1,2,3,4 0,1,2,3,4 0,1 2 3 4 5,6,7,8,9 Select B/W Dither Pattern 0,1,2,3 -1,0,1,2,3 -1,0,1,2,3 Select Tone Map -1,0 -1,0 Select Data Width variable variable B/W Thresholded Data 1 1 White Data 1 1 Black Data 1 1 B/W Dithered Data 1 1* B/W Grayscale Data 4,8 4.8 Color Data 24 Color Thresholded Data 3 Color Dithered Data 3* Chunky Thresholded Data 4 Chunky Dithered Data 4 Select Download Type 0,1 0,1,2,3 Download Binary Data variable variable Download type 0 (B/W dither) 64 64 Download type 1 (tone map) 256 256 Download type 2 (matrix) 9 Download type 3 (color dither) 192 Inverse Image 0,1 0,1 0,1 Automatic Background Control 0,1 0,1 0,1 Mirror Image 0,1 0,1 Light Source Test 0,1 0,1 0,1 Scan Window 0 0 0 Select Matrix Coefficients -1,0,1,2,3,4 Select Color Dither Pattern -1,0 Select Filter 0,1,2,3 Upload Binary Data 0,1 0,1,2,3 Change Document 0 Unload Document 0 ADF Scan Window 0 If the requested value does not exactly match a supported value, a parameter error is generated and the command is ignored. * Supported for the HP ScanJet IIc scanner only (Y resolution) x (Y scale) > 60 ppi. Range Commands Range commands will generate a parameter error if the modified value from the preprocessing steps is outside the allowable range for that command. The allowable ranges for these commands are as follows: I Ä SJ II Ä SJ Plus/SJIIp III Ä SJ IIc Minimum Value Maximum Value Range Commands I II III I II III Set X Resolution 38 12 12 600 1500 1600 Set Y Resolution 38 12 12 600 1500 1600 Set X Scale Factor 7 1 1 1578 5000/10000 6666 Set Y Scale Factor 7 1 1 1578 5000/10000 6666 Window X-Position (device pixels) 0 0 0 2549 2549 2549 Window Y-Position (device pixels) 0 0 0 4199 4199 4199 Window X-Extent (device pixels) 1 1 1 2550 2550 2550 Window Y-Extent (device pixels) 1 1 1 4200 4200 4200 Window X-Position (decipoints) 0 0 0 6118 6118 6118 Window Y-Position (decipoints) 0 0 0 10078 10078 10078 Window X-Extent (decipoints) 3 3 3 6120 6120 6120 Window Y-Extent (decipoints) 3 3 3 10080 10080 10080 Set Intensity Level -1 -127 -127 1 127 127 Set Contrast Level -127 -127 127 127 Position Scanner Element, Secondary 0 0 0 3507 3507 4199 Inquire Present Value 0 0 0 32767 32767 32767 Inquire Minimum Value 0 0 0 32767 32767 32767 Inquire Maximum Value 0 0 0 32767 32767 32767 Inquire Device Parameter 0 0 32767 32767 If the requested value is not within the allowable range, the following action is taken: 1. A parameter error is generated. 2. The greatest supported value is used if it is less than the requested value. 3. The smallest supported value is used if it is larger than the requested value. APPENDlX F - Hints for Using ADF Commands Applications written for the HP ScanJet IIc scanner should follow the following algorithm: Inquire Document Feeder Ready <ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ÚÄÄÄÄÄÄ> Clear Error ³ ³ Change Document Yes ³ ³ Inquire Error (if paper jam, handle error condition) ÄÄÄÄÄÄÄÄÙ ³ Set Xpos, Ypos, etc. ³ ADF Window ³ Inquire ADF open since last change ³ SCL Reset, set Xpos, Ypos. etc. ³ ADF Scan Window ³ Yes ... ÀÄÄÄÄÄÄÄ Inquire Paper in ADF Bin Inquire Ready to Unload Unload Document NOTE Paper loaded by the document feeder PHYSICALLY is not placed the same as paper loaded manually: it will vary by 2 mm in the Xdirection and 2.4 mm in the Y-direction. However, paper loaded by the document feeder has the same LOGICAL orientation as paper manually placed at the reference comer of the glass. The scanner assumes that sheets scanned by the ADF Scan Window command are placed or are located at the ADF load position. The application software must ensure that the paper is not moved. APPENDIX H - Output Data Types and Terminology B/W Thresholded Data The B/W thresholded data type is defined as black-and-white data. The value returned for any given pixel will be a 1 (black) if the reflectance at that location is above a specific threshold value and 0 (white) if the reflectance is less-than or equal to the threshold value. On the Scan Jet IIc, the reflectance value is taken from the output of the green channel after going through the coefficient matrix and tone map. The default is to use a matrix that maps only the input of the green channel to the output of the green channel. Other combinations of colors may be selected to contribute to the monochrome reflectance by using the Select Matrix Coefficients command and/or downloading a custom matrix, for the HP ScanJet IIc scanner. When inverted data is requested, black is represented by a 0 and white by a 1. The threshold can be set to any value by means of the intensity command. The actual threshold value used is: * If intensity < 0 then threshold = (((intensity + 127) *153) + 64) /127 * If intensity > = 0 then threshold = (((intensity * 101) + 64) /127) + 153 * These algorithms apply to the HP ScanJet Plus and ScanJet IIc scanners. The thresholded data type always returns 1-bit/pixel. Four or eight-bit thresholded data may be achieved with the grayscale data type by using a downloaded tone map which maps each pixel to 0 or 255, for the HP ScanJet Plus and ScanJet IIc Scanners. White Data The White Data type will return a 0 for every pixel scanned or a 1 if inverted data is requested. The White Data type always returns 1 bit/pixel. Four or eight-bit white data may be achieved with the Grayscale Data type by using a downloaded tone map that maps each pixel to a 0. Black Data The Black Data type will return a 1 for every pixel scanned or a 0 if inverted data is requested. The Black Data type always returns 1 bit/pixel. Four or eight-bit black data may be achieved with the Grayscale Data type by using a downloaded tone map that maps each pixel to a 255, for the HP ScanJet Plus and ScanJet IIc scanners. Grayscale Data B/W Grayscale Data is the 'n" most significant bits of the grayscale data after it has been modified by the selected tone map, where n is the selected data width. The default data width is 4-bits, which will be used if no explicit data width command is received. The only grayscale data width supported for the HP Scan Jet scanner is 4. The HP Scan Jet Plus and Scan Jet IIc scanners support 4 and 8 as data widths. White data is represented by 0 or 00 and black data is represented by F or FF. In the ScanJet IIc scanner, the grayscale data before being modified by the tone map is taken from the output of the green channel after going through the coefficient matrix. The default is to use a matrix that maps a higher amount of input from the green channel and lower amounts for red and blue, respectively, to the output of the green channel. This matrix (ID 1) approximates NTSC black and white. Other combinations of colors may be selected to contribute to the monochrome reflectance by using the "Select Matrix Coefficients" command and/or downloading a custom matrix. B/W Dithered Data The scanner implements a scheme for representing multi-level grayscale data in a one-bit-per-pixel form. An 8x8 matrix of grayscale pixels is converted to an 8x8 matrix of binary pixels by specifying a unique threshold to each pixel in the matrix. The goal of the threshold selection is to try and duplicate the tonal quality of the grayscale matrix with the binary matrix. The matrix is moved across the image to convert all pixels. A thresholding matrix is called a dither pattern. For the HP ScanJet scanner this matrix is 4x4. In the ScanJet IIc scanner, the original grayscale pixels (before being applied to the thresholding matrix) are taken from the output of the green channel after going through the coefficient matrix. The default is to use a matrix which maps a higher amount of input from the green channel and lower amounts for red and blue, respectively, to the output of the green channel. Other combinations of colors may be selected to contribute to the monochrome grayscale value by using the "Select Matrix Coefficients" command and/or downloading a custom coefficient matrix. The HP ScanJet IIc and ScanJet Plus scanners support four basic black and white dither patterns and one downloadable black and white dither pattern. Scan Jet does not support downloadable dither patterns. The patterns are referenced by a "dither ID," which can have a value of -1, 0, 1, 2 or 3. The -1 ID references the downloadable pattern, and the other IDs refer to the built-in dither patterns. The user selects the dither pattern to be used with the "Select Dither Pattern" command. The contrast and intensity of the dithered output is affected by the contrast and intensity SCL commands. A dither pattern is downloaded by the "Select Download Type" and Download Binary Data" commands. Dithered data always returns 1 bit/pixel. See Appendix C for the built-in dither patterns. Color Data (HP ScanJet IIc scanner only) The default Color Data width is 24-bits representing one pixel: 8-bits representing red reflectance, followed by 8-bits representing green reflectance, followed by 8-bits representing blue reflectance. When light is absorbed on a surface, the surface appears dark; when light is reflected, the surface appears light. In the HP ScanJet IIc scanner, the more reflectance of a color, the lower the number of the 8-bits representing the value of that pixel. So, the darkest of a color is represented by FF, while the lightest of a color is represented by 00. The 24-bit value is determined from the amount of reflectance detected by the red, green, and blue sensors modified by the coefficient matrix chosen which maps certain percentages of each colored sensor to the appropriate red, green, or blue output channel. Each color's value is then modified by a single tone map to adjust to the specified brightness and intensity. Color Thresholded Data (HP ScanJet IIc scanner only) The Color Thresholded format is 3-bits per pixel with one bit each representing the red, green and blue thresholded values for that pixel. The bits are packed so that three BYTES represents 8 pixels with the first byte containing 8 pixels' red values, followed by a byte of those 8 pixels' green values, followed by a byte of those 8 pixels' blue values. The last three bytes of a line may each contain information for pixels beyond the actual scanning window to make the data stream end on a threebyte boundary. The value returned for each color of each pixel will be a 1 (dark) if the reflectance for that color at that location (as modified by the coefficient matrix) is darker than a specific threshold value and 0 (light) if the modified reflectance is brighter than or equal to the threshold. When inverted data is requested, dark is represented by a 0 and light by a 1. The threshold can be set to any value by means of the intensity command. The same threshold is used for all three colors. The actual threshold used is: If intensity < 0 then threshold = (((intensity + 127) * 153) + 64) / 127 If intensity >=0 then threshold = (((intensity * 101) + 64) / 127) + 153 The Color Thresholded data type always returns 3-bits/pixel. 24-bit thresholded color data may be achieved with the "color" data type by using a downloaded tone map which maps each pixel to 0 or 255. Color Dithered Data (HP ScanJet IIc scanner only) The HP ScanJet IIc scanner scheme for color dithering uses the same techniques as for black and white dithering. An 8x8 matrix of color pixels is converted to an 8x8 matrix of color binary pixels by specifying a unique threshold for each color (RGB) of each pixel in the matrix. The thresholding matrix (which is called a color dither pattern) is moved across the image to convert all pixels. The HP Scan Jet IIc scanner supports one basic color dither pattern and 1 downloadable color dither pattern. The default (built-in) color dither pattern has a "color dither ID" of 0, while the downloaded color dither pattern has a "color dither ID" of -1. The user selects the dither pattern to be used with the Select Color Dither Pattern command. The contrast and intensity of the dithered output is affected by the contrast and intensity SCL commands. A color dither pattern is downloaded by the Select Download Type and Download Binary Data commands. A color dither pattern to be downloaded is 192 bytes: 64 bytes of the thresholding matrix for red sent row by row, followed by 64 bytes of the thresholding matrix for green sent row by row, followed by 64 bytes of the thresholding matrix for blue sent row by row. Color Dithered data always returns 3 bits/pixel in the format similar to that for color thresholded. See the section on "Format of Scan Data" for more detail. See Appendix D for the default color dither pattern. Chunky Thresholded Data (HP Scan Jet IIc scanner only) The Chunky Thresholded format is 3-bits-per-pixel with one bit each representing red, green, and blue thresholded values for that pixel. The bits are packed as two pixels per byte in the form ORGBORGB as 8 bits for two pixels. The first bit for each "chunlC is always zero, followed by the thresholded values for red, green, and blue for that pixel. The last byte of a line may contain information for a pixel beyond the actual scanning window to make the data stream end on a byte boundary. The value returned for each color of each pixel is determined as described above for the Color Thresholded Data type. Chunky Dithered Data (HP ScanJet IIc scanner only) The Chunky Dithered format is 3-bits-per-pixel with one bit each representing red, green and blue thresholded values for that pixel. The bits are packed as two pixels per byte in the form ORGBORGB as 8 bits for two pixels. The first bit for each 'chunlC is always zero, followed by the dithered values for red, green, and blue for that pixel. The last byte of a line may contain information for a pixel beyond the actual scanning window to make the data stream end on a byte boundary. The value returned for each color of each pixel is determined as described above for the Color Dithered Data type. Color Coefficient Matrix (HP ScanJet IIc scanner only) The color image information is sensed as an analog voltage by a CCD array, and that information is transformed to a 24-bit digital form for each pixel (8 bits red, 8 bits green, 8 bits blue) by an Analog to Digital converter. These "input" values have been divided into the three primary colors according to the physical characteristics of the sensing mechanisms and optical path. These values do not necessarily match exactly the human perception of color composition or provide a close enough approximation to the NTSC-RGB color standard. The HP Scan Jet IIc scanner has the ability to modify the color combinations sensed for each pixel to a different "output" RGB 24-bit value which mixes the desired percentage of each input color into the resulting output colors. This modification is done before any other image processing that creates the desired data type, scaling, contrast, and intensity. The proper mixture of the colors is defined by the coefficient matrix which is nine bytes representing what proportion of a color's input contributes to each of the three colors' outputs. The first byte is the coefficient for the red input contributing to the red output. The second byte is the coefficient for the red input contributing to the green output, etc. The format of each byte is a signed integer (-127 to 127) which represents the number of 64ths for that coefficient. A value of "-0" (80 hex) is a special case which results in an effective coefficient of 1. When a coefficient of 1 is desired, use the value "-0.' The default coefficient matrices used are matrix ID 0 for color, matrix ID 1 for B/W dithered and B/W grayscale data types, and matrix ID 2 for B/W thresholded type. Matrix ID 1 contains the coefficients for NTSC black and white. Matrix ID 2 is a pass through matrix which doesn't mix any of the colors and, therefore, yields the best MTF. When used with the B/W thresholded type, matrix ID 2 causes just the green channel to be used for the thresholding. The user can select a matrix other than the default for a data type AFTER the data type is selected with the Select Matrix Coefficients command. A coefficient matrix can be downloaded and would have a matrix ID of -1 by using the Select Download Type and Download Binary Oata commands. Downloaded matrices could be used to compensate for ink impurities or to drop out selected colors in a black and white scan. See Appendix E for the actual values for the matricies and examples of downloaded values. Image Data Transfer Curves (Tone Maps) (HP ScanJet Plus and ScanJet IIc scanner only) In the HP ScanJet Plus and ScanJet IIc scanners, the image data is affected by a transfer curve called a tone map. In the HP ScanJet lie scanner, the image data is modified by the coeffficient matrix and then by filtering and scaling before the tone map is applied to each color separately. The HP Scan Jet scanner does not allow for the use of tone maps. The details of the tone map are a function of the number of bits specified (1, 4, or 8) and the contrast and intensity control settings. The default power-on settings for the scanner are black and white, 1-bit mode with contrast = 0 and intensity = 0. The tone map for 1, 4, and 8-bit modes with default contrast and intensity for the black and white and color data types are: 1-bit mode - a straight-line mapping of 0% to 100% reflectance which is then thresholded or dithered, depending upon the data type selected. 4-bit mode - a straight line mapping of 4% to 74% reflectance into an output of 0 to 15. 8-bit mode - a straight line mapping of 0% to 100% reflectance into an output of 0 to 255. The default tone map for all the color data types is a straight line mapping of 0% to 100% reflectance into the appropriate data format. The tone map for dithered 1-bit mode or 8-bit mode becomes non-linear as the contrast and intensity are changed from 0. The detailed algorithm for the tone map generation is given in Appendix B. The tone map used for a scan is generated when the scan command is given using the data type, contrast, and intensity intended for that scan. Scaling The limits on the scaling of an image depend on the current scan resolution. Because scan resolution effects scaling, the user should set the scan resolution first, then inquire the limits of scaling, and then set the desired scales. Failure to follow this order of commands risks a scaling error. The relationship between scan resolution and scaling for HP ScanJet and ScanJet IIp scanners are as follows: 1200 <= (scale factor) x (resoultion) <= 120000 (HP ScanJet IIp scanner) 1200 <= (scale factor) x (resolution) <= 60000 (HP ScanJet Plus scanner) 1200 <= (scale factor) x (resolution) <= 80000 (Hp ScanJet IIc scanner) 3750 <= (scale factor) x (resolution) <= 60000 (HP ScanJet scanner) NOTE: Scaling is Data Width dependent Unlike the HP ScanJet Plus scanner (HP 91915A), the ScanJet has an additional hardware constraint that can further restrain the maximum limit for scaling of grayscale images. This restriction occurs when a grayscale scan is requested that is over 80 percent of the full length scan line and when scaling is near the maximum allowable for that resolution. This restraint is characterized by the following equation: (scale factor) x (resolution) x (bytes/pixel) x (extent) < 2048 bytes (scale factor = 100% = 1.00) In the HP ScanJet IIc scanner the result of scaling is more accurate than it's predecessors'. In describing the methods used, "resolution" will mean the physcial pixels per inch that the scanner uses which is ("SCL resolution" + "SCL scaling") / 100. For resolutions greater than 60 ppi in the Y-direction, the scan speed is adjusted so that the requested resolution is the true resolution. For resolutions less than 60 ppi, the scanner scans at 60 ppi and uses a binary rate multiplier scheme to drop lines until the desired resolution is obtained. In the X-direction, the image is always scanned at 400 ppi. The HP ScanJet IIc scanner uses linear interpolation to generate new pixels to provide an apparent stream of 800 ppi to drop pixels from to provide the desired resolution. Between 400 and 800 ppi a straight rate multiplier is used to select the pixels to be dropped. At 400 ppi, the raw data is used; below 400 ppi, a modified rate multiplier scheme is used to select the pixels to be dropped. [Chart of Scaling Limits skipped] APPENDIX J - Scanner Driver Installation and Use Installing the Driver (For PC AT backplane only) To install SJDRIVER.SYS (for the ScanJet and ScanJet Plus), or SJII.SYS (for ScanJet IIc and ScanJet IIp), copy the following command line to the config.sys file. DEVICE = SJDRIVER.SYS (for the ScanJet and ScanJet Plus) DEVICE = SJII.SYS (for the ScanJet IIc and ScanJet IIp) Reboot your system after saving your updated CONFIG.SYS file. A message will be printed on your screen when the computer boots to verify that the driver has been installed successfully. If the installation was not successful, the switch settings on your scanner interface board may need to be changed. Using the Driver A device named "HPSCAN" has now been installed onto your system. The device "HPSCAN" can be opened the same way that files are opened, and data can be transferred to and from the scanner by writing and reading from the opened device. If a program tries to read more data from "HPSCAN" than the scanner sends, the driver will only return the number of bytes that are available. If the driver ever times out waiting for the scanner to respond, an MS-DOS "Abort, Retry, Ignore?" message will be printed on the screen. Reading Image Data from The HP ScanJet, ScanJet IIp and Scan Jet IIc Controlling an HP scanner directly using the Scanner Control Language, SCL, requires sending commands and receiving data through the device driver file "HPSCAN." Unfortunately, most C compilers for the PC will allow driver files to be opened in binary mode with the standard open function, but the results can be unpredictable. Although binary data might be clearly specified in the parameter list of open, DOS will still interpret the data from the input stream. The sample code below remedies the problem. The driver HPSCAN must be set up to transfer data in an untranslated mode. This is accomplished by sending a DOS interrupt 21, function 44, to configure the driver for binary data. Function 44 is used for I/0 control and can be invoked to make sure that DOS does not translate any of the binary data coming in from the HP ScanJet. Sample Code for Reading Data In Binary Mode: # include <> scan handle = open("HPSCAN", O_BINARY | O_RDWR); if(file handle == -1) { printf("couldn't open HPSCAN /n"); return(1); } raw(scan handle); /* RAW(handle) Does an IOCTL call which puts handle into binary (untranslated) mode. */ raw(handle) int handle; union REGS inregs, outregs; inregs.h.ah = 0x44; /* DOS IOCTL Function */ inregs.h.al = 0; /* get device information */ inregs.x.bx = handle; /* specify printer handle */ intdos(&inregs,&outregs); /* INTERRUPT 21h */ if((outregs.x.dx & 0x80) >> 0) /* if handle is a character device */ { inregs.h.dh = 0; inregs.h.dl = outregs.h.dl | Ox20; /* set binary mode */ inregs.h.al = 1; /* set device mode */ intdos(&inregs, &outregs); /* INTERRUPT 21h */ } For more information about DOS device drivers, consult the technical reference manual for your particular computer.