•  Back 
  •  Driver types 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File13.6.4.1  Scanner driver group                                     TOS

Introduction: With bi-level data, a set bit corresponds to a pixel 
that is present. With multi-value data, a 0 corresponds to `nothing` 
and with increasing values the relevant colour intensity or brightness 
rises.

Warning: With commands in the 10xH group, greyscale images are 
inverted!

  14H  W  Scanner description
          If this WORD contains the value 0 then the scanner/driver is
          not yet initialized, execute command 105H
          Bit 0: Bi-level possible
              1: Dithering possible
              2: Multi-value possible
              3: Multi-value and dithering possible
              4: Bi-level colour possible
              5: Colour dithering possible
              6: Multi-value in colour possible
              7: Multi-value in colour and dithering possible
              8: Compression of data (see below) possible
              9: Block-wise return possible
             10: Single sheet feed with separate command
             11: Single sheet feed automatic
             12: Prescan possible
             13: Virtual memory management possible
                 (GDPS-Version >= 1.10)
             14: Reserved (0)
             15: Reserved (0)
            Multi-value and dithering: Special mode, always 2 bits/pixel
  16H  W  Number of colours
  18H  W  Possible multi-value bit depths
          Makeup:  Bit 0 set: Monochrome possible
                   Bit 1 set: 2 grey-steps possible
                   Bit 2 set: 4 grey-steps possible
                   Bit 3 set: 8 grey-steps possible
                   etc...
  1AH  W  Reserve scanner
  1CH  W  Command to scanner (0=Ready, 1-FFH reserved!!!)
  1EH  L  Pointer to command structure

A scanner driver with its own user interface is assumed here. If a 
program wants to address the scanner driver, then this is done as 
follows:

   a) Wait until WORD 1AH = 0 (scanner free)
   b) Reserve scanner be entering a WORD in 1AH
   c) Create a command structure
   d) Enter the pointer to the command structure in 1EH
   e) Enter the command in 1CH
   f) In an EVENT loop (!!) (timer- or multi-event) wait until the
      command WORD of the scanner driver is set to 0 again
   g) Repeat steps from c) onwards as often as required
   h) Release scanner (enter 0 in 1AH)

The command structure to be made available by the calling program has 
three tasks:

   a) Passsing of the command structure
   b) Return of a success or error message
   c) Return of the parameters used

Makeup of the command structure:

   00H  W  Return value, is initialized by the calling program to 0.
           After processing the command, the scanner driver enters
           0xFFFF (=OK) or a positive error-message here.
           If the scanner is operating in block mode, then 0xFFFE is
           entered after a block and 0xFFFF after the last block. If
           working in block mode AND in colour, there are two options:
           a) The scanner scans the colour separations individually;
              then the passing will proceed as above, but several
              times corresponding to the number of colours.
           b) The scanner scans all colours simultaneously; in that
              case 0xFFFD is entered after the blocks. The returned
              block then consists of 'number of colours' equal-sized
              areas.
   02H  W  Permitted scan modes. Makeup of this WORD is as for 14H;
           a set bit denotes that the scanner driver may use the
           corresponding mode.
   04H  W  Permitted bit depths (makeup as above for 18H)
   06H  L  Pointer to memory
   0AH  L  Number of bytes in memory (Return: Number of bytes used)
   0EH  W  Bytes per scanline, or 0 (always mod 2!)
   10H  W  Number of scanlines, or 0
   12H  W  Width of the image in 1/10 mm, or 0
   14H  W  Height of the image in 1/10 mm, or 0
   16H  W  Resolution in main scan direction (X) in dpi, or 0
   18H  W  Resolution in sub scan direction (Y) in dpi, or 0
           (For return: Resolution = Resolution * zoom factor!)
   1AH  W  Modulo value for scanlines (in bytes, e.g. 2 = 2*n bytes
           per scanline)
   1CH  W  X-position of the image in 1/10 mm
   1EH  W  Y-position of the image in 1/10 mm

Since GDPS Version >= 1.10:
   20H  L  Serial number of the calling program
   24H  W  (!I)add_bits:(!i) Additional memory required by program (in bits
           per pixel)
   26H  L  Pointer to 'Dchange_pointer' (function of the vmm)
   2AH  L  Pointer to 'Dupdate' (function of the vmm)
   2EH  W  (!I)v_handle(!i) READ (vmm)
   30H  W  (!I)v_handle(!i) WRITE (vmm)
   32H  W  (!I)virt_flag(!i) (1 = vmm being used)

vmm = virtual memory management

After processing a command the scanner driver enters the actually used 
values into this data structure.

If the image size is to remain fixed, then this can be defined with 
the WORDS 0EH, 10H or 12H, 14H, 1CH, 1EH. If both value pairs are 
preset, the default in bytes will be used. If the scanner is not able 
to scan in this format, a change may be made to suitable values if 
necessary; therefore, check the return vales!!

Compression:

Bi-level and dither data are always packed in such a way that 8 pixels 
are present in a byte. For this the first pixel is entered in the most 
significant bit.

Multi-value data are present either uncompressed, in which case one 
pixel occupies exactly one byte. Here (with fewer than 256 grey steps) 
the data is always formatted to the MS bit, and the LS bits are filled 
if appropriate (depending on the scanner with 0 or 1). In compressed 
form the multi-value data are packed in such a way that byte borders 
are not exceeded; if necessary empty bits are filled with (depending 
on the scanner) with 0 or 1:

                 +--+--+--+--+--+--+--+--+
   2 bits/pixel  |B1|B0|B1|B0|B1|B0|B1|B0|   -> 4 pixels/byte
                 +--+--+--+--+--+--+--+--+

                 +--+--+--+--+--+--+--+--+
   3 bits/pixel  |B2|B1|B0|--|B2|B1|B0|--|   -> 2 pixels/byte
                 +--+--+--+--+--+--+--+--+

                 +--+--+--+--+--+--+--+--+
   4 bits/pixel  |B3|B2|B1|B0|B3|B2|B1|B0|   -> 2 pixels/byte
                 +--+--+--+--+--+--+--+--+

                 +--+--+--+--+--+--+--+--+
   5 bits/pixel  |B4|B3|B2|B1|B0|--|--|--|   -> 1 pixel/byte
                 +--+--+--+--+--+--+--+--+

                 +--+--+--+--+--+--+--+--+
   6 bits/pixel  |B5|B4|B3|B2|B1|B0|--|--|   -> 1 pixel/byte
                 +--+--+--+--+--+--+--+--+
   etc.

If the compression bit is not set in the command structure, then the 
data are decompressed by the scanner driver if necessary. If the bit 
is set, however, then after processing the command one has to test 
whether the data are really compressed.

Fixed commands:

   100H: Scan
           The user dialog is called up, and if appropriate the scan
           process is performed
   101H: Continue
           In block mode this command continues the scan
   102H: Scan without dialog
           The scanning process is initiated without further user
           intervention; the same user-set parameters are used as
           for the previous scan
   103H: Next sheet
           The next sheet is fed in from the single-sheet tray
   104H: Prescan
           Executes a prescan with set parameters
   105H: Initialize scanner/driver
           Gets device description from scanner

Commands 102H and 103H are meant specially for automatic optical 
character recognition (OCR).

Since GDPS Version 1.10 new commands exist (as above, but instead of 
10xH, 20xH is used). If these commands are used, one can work in a 
virtual mode provided virt_flag=1. Furthermore greyscale images with 
these commands are delivered as follows:

      0=black
    255=white

Warning: With 20xH commands the calling program must pass the extended 
command structure according to GDPS 1.10 !!!

Error-messages in return value:

   FFFEH: Block ready, further blocks follow
   FFFFH: Scan process (possibly for one colour) completed, last (or
          only) data block is present
      0H: Wait and have a cup of tea (if appropriate wait with an
          EVENT loop)
      1H: Unknown command
      2H: Scanner error
      3H: Abort by the user
      4H: Out of paper (only with single-sheet feed)
      5H: Out of memory: The user has set too large a paper format
      6H: Scanner not yet initialized

The error-messages are displayed to the user of the driver. They only 
serve as information for the calling program.