home *** CD-ROM | disk | FTP | other *** search
/ Tools en Utilities / CDASS_5.ISO / shell / file / docmkr33.arj / SAVEPCX.DOC < prev   
Encoding:
Text File  |  1992-11-27  |  24.5 KB  |  475 lines

  1.  
  2.  
  3.  
  4.          -----------------------------------------------------------
  5.          --                                                       --
  6.          --                 Save PCX Version 1.00                 --
  7.          --                                                       --
  8.          --  (C) Copyright 1992, Prometheus Systems Incorporated  --
  9.          --                                                       --
  10.          --                Save PCX User's manual                 --
  11.          --                                                       --
  12.          -----------------------------------------------------------
  13.  
  14.  
  15.  
  16.      Introduction.
  17.      -------------
  18.      SavePCX is a very small (less than 3Kb resident) which allows you
  19.      to capture images from the graphics screen, and save them as PCX
  20.      type pictures.
  21.  
  22.  
  23.      Status.
  24.      -------
  25.      SavePCX is Freeware.  It is completely free... however, SavePCX is
  26.      still copyrighted and you are not allowed to make any changes to the
  27.      program or the documentation.  You are allowed to distribute this
  28.      program, but you are not allowed to sell it, you have to GIVE the copy
  29.      away, you may not regain any losses made by distributing this program.
  30.      Also, SavePCX may NOT be combined in a package of any sorts unless the
  31.      package is COMPLETELY free.  If you give a copy to a friend make sure
  32.      he gets this documentation too.
  33.  
  34.  
  35.      Installation.
  36.      -------------
  37.      Since SavePCX is very small in size, this utility should not cause
  38.        any problems, even in systems with little memory.
  39.  
  40.      Just type SavePCX at the DOS prompt to load SavePCX in memory.  No
  41.        parameters are needed.
  42.  
  43.      To load SavePCX in the UMB, type
  44.           LH SavePCX               or
  45.           LOADHIGH SavePCX
  46.      Be sure you have an UMB manager loaded (EMM386.EXE, QEMM.SYS,
  47.        QRAM.SYS...).
  48.  
  49.      If you try to install a second copy of SavePCX, a message (Already
  50.        in memory) will appear on screen and the second copy will not be
  51.        installed.
  52.  
  53.  
  54.  
  55.      How it works
  56.      ------------
  57.      SavePCX is a resident screen-capture utility. Once loaded, it
  58.        will remain in memory and can be activated by pressing the "Hot
  59.        Key" (Ctrl+Alt+S).
  60.      Once activated, SavePCX will check the video mode and save the
  61.        graphics screen into the current directory. The file is placed in
  62.        the current drive and path.  If there is no more room for the
  63.        file the program will do it's best to close the file and return
  64.        you to your task.
  65.  
  66.      Every file made by this utility can be recognized by the name
  67.        PSInnnn.PCX where 'nnnn' represents a number from 0000 to 9999.
  68.  
  69.      An existing file cannot be overwritten by this utility, it first
  70.        checks the filename, if the name already exists it increments the
  71.        number and checks again until the filename doesn't exist.
  72.  
  73.  
  74.  
  75.      Operations.
  76.      -----------
  77.      The operation of SavePCX is easy and can be done in a few simple
  78.      steps.
  79.  
  80.      First load SavePCX in memory.
  81.  
  82.      Once loaded, a message that SavePCX is now resident or was already
  83.        resident will appear on screen and you will be returned to the
  84.        DOS prompt.  Except for a small reduction in system memory (3Kb),
  85.        you may continue using your computer normally.
  86.  
  87.      Second, now that SavePCX is an extension of DOS, it may be
  88.        activated while in any program. The way for doing this is as
  89.        follows:
  90.  
  91.      Hot Key: This combination of keys is used to activate the program.
  92.        To avoid interfering with the current program, the keyboard will
  93.        respond normally until these keys are pressed. Once the hot key
  94.        is pressed, the current operation is suspended and the screen is
  95.        saved on disk (current drive and directory).  The hot key for
  96.        SavePCX is Ctrl+Alt+S.
  97.  
  98.  
  99.  
  100.      What is saved.
  101.      --------------
  102.      SavePCX will do it's best to identify the active video mode and
  103.      save what you see on screen.
  104.      Following video modes are supported.
  105.  
  106.      Mode 04h : CGA 320*200, 4 colour.
  107.                 Although this CGA mode can make use of any of four
  108.                 different colour schemes, due to the limitations of the
  109.                 PCX format version 3.0, the correct colour scheme will
  110.                 not be saved.  This will usually not be a problem since
  111.                 most drawing packages only use the Cyan/Magenta/White
  112.                 (CMW) colour scheme.
  113.      Mode 05h : CGA 320*200, 4 gray scale.
  114.                 This video mode is technically the same as mode 04h.
  115.                 Again due to limitations in the PCX format version 3.0,
  116.                 the gray scales are not saved.  The picture is saved
  117.                 just like it was mode 04h
  118.      Mode 06h : CGA 640*200, Monochrome.
  119.                 Again, Although it's possible to set the colour of the
  120.                 pixels, this colour is not saved.
  121.      Mode 07h : Hercules 720*348 monochrome.
  122.                 This is really an odd one out.  Since there is no sure
  123.                 way to tell if the Hercules card is in graphics mode,
  124.                 (there IS a technique to see if a TRUE Hercules is in
  125.                 graphics mode, testing has shown that this technique
  126.                 does not work for most hercules clones).
  127.                 SavePCX always assumes graphics mode is active when the
  128.                 hot key is pressed.  If, at the time the hot key is
  129.                 pressed, alfanumeric (text) mode is active, the picture
  130.                 will be saved, but it will probably hold nothing but
  131.                 garbage.
  132.      Mode 0Dh : EGA 320*200, 16 colour.
  133.      Mode 0Eh : EGA 640*200, 16 colour.
  134.      Mode 0Fh : EGA 640*350, Monochrome.
  135.      Mode 10h : EGA 640*350, 16 colour.
  136.      Mode 11h : VGA 640*480, Monochrome.
  137.      Mode 12h : VGA 640*480, 16 colour.
  138.                 In all modes from 0Dh through 12H, there's a difference
  139.                 when you have an EGA or VGA card installed.
  140.                 If you have an EGA card, the picture will be saved with
  141.                 standard palette, Page 0.  This is due to the fact that
  142.                 it's not possible to read out the EGA registers.
  143.                 If you have a VGA card, SavePCX will correctly save the
  144.                 active page, correct palette colours and in the case the
  145.                 screen dimensions have been changed, save the entire
  146.                 video buffer (It's possible to change the dimensions of
  147.                 the video buffer but still keeping the same screen size).
  148.      Mode 13h : VGA 320*200 256 colour.
  149.      Tweaked  : Also called Mode-X, 13h/4, VGAX, Unchained VGA...
  150.                 This is a very nifty (undocumented) VGA mode, it's a
  151.                 mode that allows 256 colours but offers you multiple
  152.                 screen pages (unlike mode 13h).  This mode is used by
  153.                 some games (Ultima Underworld (Origin), Red Baron
  154.                 (Dynamix)...) and lots of demos (Cronologia (Cascada),
  155.                 Vectordemo (UltraForce), Unreal (Future Crew)...).  It's
  156.                 a hell to program in this mode but the gains can be
  157.                 enormous.  You can fill the screen up to 4 times as fast
  158.                 as compared to mode 13h.
  159.                 SavePCX is probably the ONLY screen capture program
  160.                 around which saves screens in this mode. Problem is most
  161.                 games/demo's tend to take complete control of the
  162.                 keyboard and thus render SavePCX useless in that case.
  163.                 Nonetheless it's here.
  164.  
  165.  
  166.      Warning.
  167.      --------
  168.      To avoid disk drive errors, activation of SavePCX during disk
  169.        operations is not recommended (because SavePCX uses the disk
  170.        also).  Under normal circumstances, pressing the Hot Key while
  171.        you are reading/writing files, shouldn't cause any problems,
  172.        SavePCXC will wait until DOS has finished reading/writing. If you
  173.        are using a program which reads/writes the disk directly (Like
  174.        Disk Optimizers (PCTools Compress, Norton Speeddisk,...)), it's
  175.        best to reboot first, to avoid wrecking your harddisk by pressing
  176.        the Hot Key.
  177.  
  178.      To avoid a problems with TSR-utilities (not only SavePCX).
  179.        1° : Do not load any TSR programs when in a DOS Shell. This will
  180.             result in memory fragmentation ("memory allocation error")
  181.             when quitting the program you invoked the DOS shell from.
  182.             If no error occurs when quitting the program you invoked the
  183.             shell from, you will loose a considerable amount of memory
  184.             because the program is terminated but is not removed from
  185.             memory.
  186.        2° : Most programs which have a shell built-in, release all
  187.             unused memory.  When trying to return to the program you
  188.             shelled from, the computer will hang because the program can
  189.             not re-allocate it's freed memory.
  190.        3° : Try not to run a program which uses the same combination of
  191.             keys as the TSR does.
  192.  
  193.  
  194.  
  195.      About the PCX File format.
  196.      --------------------------
  197.      This paragraph is only for those who are looking to incorporate
  198.      pictures in their own programs or want to learn about the structure
  199.      of PCX files. If you aren't one of these, just skip this section.
  200.      This section requires you to know how to program the video
  201.      hardware, because only the PCX format is discussed here.
  202.      First of all I'd like to mention that there are a lot of
  203.      descriptions of the PCX format around, but none of them (even the
  204.      one by ZSoft) is correct on all counts.  The format description
  205.      here will probably be the easiest guide around and is based on
  206.      a lot of tests done on PCX files created by various programs.
  207.      The PCX-pictures created by SavePCX conform to the ZSoft
  208.      specification.  Some of the special cases which do not conform to
  209.      the ZSoft specification are marked with an asterix (*), it's up to
  210.      you to decide to incorporate the exception in your loader.  If you
  211.      need a PCX write routine, stick to the PCX convention for maximum
  212.      compatibility.
  213.  
  214.      the PCX format supports several types of images, monochrome, 16
  215.      colour, 256 colour (8 bit) and even true 24 Bit colour.  Altough
  216.      these are the standard (PC) formats, you may have to accomodate for
  217.      even more types when you want to write a general purpose PCX
  218.      loading/writing routine, images from the amiga have a few more
  219.      possibilities (8,32 and 64 colour, 16 colour Bitpacked...).
  220.      Most probably however you'll need a PCX routine which
  221.      correctly reads one specific type of file.
  222.  
  223.      The PCX file begins with a 128 byte header.  Usually you can ignore
  224.      the header, since your images will probably all have the same
  225.      resolution and number of colours.  If you want to process different
  226.      resolutions or colours, you will need to interpret the header
  227.      correctly.  The remainder of the file consists of encoded graphic
  228.      data.  The encoding method is a simple byte oriented run-length
  229.      technique.
  230.  
  231.      The header (All Bytes are unsigned, Words are signed) :
  232.  
  233.      Offset  Item          Type      Description comment.
  234.      ------  ------------  --------  -----------------------------------
  235.      0       Manufacturer  Byte      Should be 10 (0A Hex).
  236.                                      This is a flag that can be checked
  237.                                      to see if it's a ZSoft compatible
  238.                                      PCX.
  239.                                      (*) even those not conform to the
  240.                                      ZSoft specification have a 10 here,
  241.                                      I haven't found any programs which
  242.                                      have their own value here.
  243.      1       Version       Byte      The version number of the PCX file.
  244.                                      0 = V2.5 of PC Paintbrush
  245.                                      2 = V2.8 with palette
  246.                                      3 = V2.8 without palette
  247.                                      4 = PC Paintbrush for Windows (PC
  248.                                          Paintbrush Plus for Windows
  249.                                          uses Ver 5)
  250.                                      5 = Version 3.0 and higher of PC
  251.                                          Paintbrush and PC Paintbrush +
  252.                                          includes Publisher's Paintbrush.
  253.      2       Encoding      Byte      1 = .PCX run length encoding
  254.                                      (*) 0 = No crunching. there seem to
  255.                                      be some files around which are not
  256.                                      crunched with the RLE, the graphic
  257.                                      data is stored as a raw image.
  258.      3       BitsPerPixel  Byte      Number of bits to represent a pixel
  259.                                      (per plane) for PC 16 colour images
  260.                                      this is 1.
  261.                                      Allowed values are 1, 2, 4, 8.
  262.                                      (*) the 24 bit images have 24 this
  263.                                      is an extention to the PCX format
  264.                                      which has (to my knowing) not yet
  265.                                      been approved of by ZSoft.
  266.                                      (*) other values are possible, some
  267.                                      Amiga PCX files actually have 5 (32
  268.                                      colour) altough most 32 colour
  269.                                      images have 1 but 5 planes.
  270.      4       XMin          Word      \  Image dimensions.
  271.      6       YMin          Word       \ XMin and YMin are usually 0
  272.      8       XMax          Word       / but in the PCC (PCX Blocks) the
  273.      10      YMax          Word      /  value is actualy the screen
  274.                                         coordinates from which the block
  275.                                         was taken.
  276.                                         Since counting normally starts
  277.                                         at 0, XMax and YMax will have
  278.                                         one less than the number of
  279.                                         pixels per colum/row.
  280.      12      HDPI          Word      Horizontal resolution of image in
  281.                                      DPI
  282.      14      VDPI          Word      Vertical resolution of image in DPI
  283.      16      Palette       48 bytes  Colour palette setting (See later)
  284.      64      Reserved      1 byte    Should be 0.
  285.                                      (*) In Paintbrush this byte usually
  286.                                      holds the number of the video mode
  287.                                      the picture was made in.
  288.      65      Planes        Byte      Number of colour planes.
  289.      66      BytesPerLine  Word      Number of bytes to allocate for a
  290.                                      scanline plane.  MUST be an EVEN
  291.                                      number.
  292.                                      (*) A *LOT* of programs actually
  293.                                      have an ODD number for bytesPerLine.
  294.                                      oddly enough most PCX loaders don't
  295.                                      load pictures correctly with an odd
  296.                                      number. It's easy enough to
  297.                                      accomodate this in a PCX loader.
  298.                                      There's even a program around
  299.                                      (forgot the name) which can write
  300.                                      a PCX file with ODD BytesPerLine
  301.                                      and can not read the file it just
  302.                                      saved.
  303.      68      PaletteInfo   Word      How to interpret palette
  304.                                      1 = Color/BW
  305.                                      2 = Grayscale (ignored in PB IV/IV+)
  306.      70      HScreenSize   Word      Horizontal screen size in pixels.
  307.      72      VScreenSize   Word      Vertical screen size in pixels.
  308.      74      Filler        54 Bytes  Blank to fill out the 128 byte
  309.                                      header.  Should all be 0.
  310.                                      (*) Some programs store proprietary
  311.                                      information here.
  312.  
  313.      When making a PCX loader you can simply ignore most values here.
  314.      The ones you need are : BitsPerPixel, XMin, XMax, YMin, YMax,
  315.      Planes and BytesPerLine.  Depending on the type of file you'll need
  316.      Version and Palette.
  317.  
  318.      Reading .PCX files :
  319.      First find the pixel deimensions of the image by calculating
  320.       XSize = XMax - XMin +1   and  YSize = YMax - YMin + 1.
  321.      Then calculate how many bytes are required to hold on complete
  322.      uncompressed scanline :  ScanlineSize = Planes * BytesPerLine.
  323.      Because there are always an even number of BytesPerLine, there will
  324.      probably be unused data at the end of each plane line.
  325.      You can now begin decoding the first scan line, read the first byte
  326.      of data from the file.  if the top two bits are set, the remaining
  327.      six bits in the byte show how many times to duplicate the next byte
  328.      in the file.  If the top two bits are not set, the first byte is
  329.      the data itself, with a count of one.
  330.      Following procedure can be used :
  331.  
  332.         while not endofscanline do
  333.           begin
  334.             get a byte (X) from file
  335.             if the top two bits of X are 1 then
  336.               begin
  337.                 Count = 6 lowest bits of X
  338.                 get a new byte (Data) from file
  339.               endif
  340.               else begin
  341.                 Count = 1
  342.                 Data  = X
  343.               endelse
  344.             Store Count bytes of Data in Output Buffer (or to screen)
  345.           endwhile
  346.  
  347.      Continue decoding the rest of the line.  Keep a running subtotal of
  348.      how many bytes are moved and duplicated into the output buffer.
  349.      When the subtotal equals ScanlineSize, the scanline is complete.
  350.      If the subtotal is larger than ScanLineSize, the PCX file is
  351.      probably corrupt.
  352.      For a picture with more than one plane (16 Colour PC pictures have
  353.      4 planes), the planes are stored one after the other. Plane 0
  354.      first, Plane 3 last (the sequence of bytes will then be Red plane,
  355.      Green plane, Blue plane and Intensity plane).
  356.      The RLE can cross the planes, that is, it's not assured there will
  357.      be a decoding break at the end of each break (subtotal equals
  358.      BytesPerLine).  (*) Most documentations are wrong here, stating a
  359.      decoding break MUST occur at the end of each plane.  They thus
  360.      write PCX files with a decoding break at the end of each plane,
  361.      strangely enough they do manage te READ PCX files without decoding
  362.      breaks.  ! SavePCX does not include a decoding break a the end of
  363.      each plane.
  364.      Use XSize to know what are valid pixel bits (bytes), and
  365.      BytesPerLine to shows where each plane ends within the scanline.
  366.      Continue decoding the remainder of the IMAGE data, (YSize
  367.      scanlines).  Do not just read to end-of-file.  There may be
  368.      additional data after the end of the image.
  369.  
  370.      EGA/VGA 16 Colour Palette Information.
  371.      In standard RGB format, the data is stored as 16 triplets which can
  372.      be found in the PCX header (Palette).  Each triplet is a 3 byte
  373.      quantity of Red, Green, and Blue values.  The values can range from
  374.      0-255, so some interpretation may be necessary.  On EGA for
  375.      example, there are 4 possible levels of RGB for each color.  The
  376.      simplest solution is to divide each value by 64 (shift right 6
  377.      bits).
  378.      On the VGA there are 64 possible levels of RGB for each colour.
  379.      You will have to set the VGA DAC palette from color offsets
  380.      obtained from the EGA palette registers (get it ? :-) ).
  381.  
  382.      VGA 256 Colour Palette.
  383.      The 256 Colour palette is formatted and treated the same as the 16
  384.      colour palette, except that it is substantially longer (256
  385.      triplets).  The palette (number of colours * 3 bytes per colour) is
  386.      appended to the end of the .PCX file, and is preceded by a 12
  387.      (0CHex).  Since the VGA DAC expects a palette value to be 0-63 in
  388.      stead of 0-255, you need to divide the values read in the palette
  389.      by 4 (Shift right 2 bits).
  390.      To access the 256 colour  palette.  First check the version number
  391.      in the header; if it contains a 5 there is a palette.  Second, read
  392.      to the end of the file and count back 769 (3*256+1) bytes. the byte
  393.      you should find there is 12, showing the presence of a 256 colour
  394.      palette.
  395.  
  396.      These two are the only types of picture which are well defined :
  397.      Monochrome images,
  398.      4 colour CGA pictures : No matter what's in the Palette, the
  399.      picture always seems OK, the palette information is filled with
  400.      all kind of different values depending on what program created the
  401.      PCX file.  Simply put, treat monochrome images as Black/White
  402.      whatever the value in the palette. and treat 4 colour images with
  403.      the default CGA colour set (Black, Cyan, Magenta, White).
  404.  
  405.      (*) 32 and 64 colour images have a palette identical to the 256
  406.      colour palette, but with 32 or 64 entries in stead of 256.
  407.      (*) 8 colour images can have either an 16 colour or 256 colour
  408.      compatible palette.  The best way to treat these images is as
  409.      follows, if it has a palette appended (like the 256 colour
  410.      pictures) use that one, overriding the values in the header. If
  411.      there's no appended palette, use the Palette in the Header.
  412.      (*) 24 Bit pictures have no palette, the pixels should be treated
  413.      as 24-bit (true colour).  To display these images on a standard
  414.      VGA, you'll either have to dither the picture or set up a default
  415.      palette and calculate an 8 bit value for each 24 bit value (colour
  416.      reduction).
  417.  
  418.      To make a PCX Write routine, just reverse it all :-) (come on do
  419.      something yourself).  Just incorporate a Version 5 PCX write only,
  420.      most PCX loaders read those anyway.
  421.      The values in HDPI, VPDI are used for scanned images, depicting the
  422.      resolution the picture was scanned at.
  423.      HDPI, VDPI, PaletteInfo, VScreenSize, and HScreenSize, just leave
  424.      them at 0.  Fill up the Header Palette with a default EGA setting.
  425.  
  426.  
  427.      Contacting PSI.
  428.      ---------------
  429.      You can contact PSI on following address :
  430.  
  431.                        Olivier Reubens
  432.                        Lippenslaan 205
  433.                        8300 Knokke-Heist
  434.                        Belgium
  435.  
  436.      Or you can call the PSI BBS.
  437.  
  438.                        FUN-derbird
  439.                        +32-(0)50-620112
  440.                        Speeds From 1200 up to 16.8k (MNP4-5, V42 & V42bis)
  441.                        2.2 Gigabyte online
  442.                        Lots of Pascal, C, Asm sources
  443.                        Loads of GIF and MOD
  444.                        and more.......
  445.  
  446.  
  447.  
  448.      Disclaimer
  449.      ----------
  450.      The software, diskettes, and documentation are provided "AS IS".
  451.      There is no warranty of merchantability, no warranty of fitness for
  452.      a particular use, and no warranty of any kind, either expressed or
  453.      implied regarding the software, diskettes, or documentation.
  454.      Accordingly, the entire risk as to the use, results and performance
  455.      of the software and documentation is assumed by you.  In no event
  456.      will Prometheus Systems Incorporated be liable to you or any one
  457.      else for any consequential, special, or indirect damages resulting
  458.      from possession, use, or malfunction of this product, including
  459.      without limitation, damage to property and, to the extent permitted
  460.      by law, damage for personal injury, even if Prometheus Systems
  461.      Incorporated has been advised of such damages or loss. Some
  462.      Countries (states) do no allow limitations on the duration of
  463.      implied warranties and/or the exclusion or limitation of incidental
  464.      or consequential damages, and thus the preceding limitation and/or
  465.      exclusions and limitations may not apply to you.  This warranty
  466.      gives you specific legal rights, and you may have other rights
  467.      depending on the laws in your country (state).  You agree that the
  468.      liability of Prometheus Systems Incorporated arising out of any
  469.      kind of legal claim (whether in contract, tort, or otherwise) will
  470.      not exceed the amount you originally paid for the use of this
  471.      product.
  472.  
  473.  
  474.  
  475.