home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / graphics / cv2img11 / conv2img.txt < prev   
Text File  |  1985-11-19  |  18KB  |  387 lines

  1.                        Convert to .IMG
  2.                        ======= == ====
  3.  
  4.                              by
  5.  
  6.                        Craig W. Daymon
  7.  
  8.             *************************************
  9.             ***                               ***
  10.             ***   This program is ShareWare   ***
  11.             ***                               ***
  12.             *************************************
  13.             *                                   *
  14.             *     If you use this program,      *
  15.             *     you are requested to register *
  16.             *     as a legitemate user by       *
  17.             *     sending $15 (US) to:          *
  18.             *                                   *
  19.             *     Craig W. Daymon               *
  20.             *     33 Chestnut Valley Drive      *
  21.             *     Doylestown, PA                *
  22.             *     18901 - 2216                  *
  23.             *     USA                           *
  24.             *                                   *
  25.             *************************************
  26.  
  27.  
  28.             Copyright 1989, 1990 - Craig W. Daymon
  29.  
  30.           *This file last updated on:
  31.  
  32.             *************************************
  33.             *                                   *
  34.             *          March 22, 1990           *
  35.             *                                   *
  36.             *************************************
  37.  
  38. *************************************************************************
  39.  
  40.    THIS IS VERSION 1.10 - PLEASE DISTRIBUTE THIS TEXT WITH THE PROGRAM
  41.  
  42. *************************************************************************
  43.  
  44. PROGRAM OPERATION:
  45. ======= =========
  46.  
  47. General:
  48. -------
  49.  
  50.     The program will save IMG files in an uncompressed format.  This
  51.     means that some compressed IMG files can grow significantly in
  52.     size after conversion.  The program WILL check available disk
  53.     space before saving ANY file.  The IMG files should be compatible
  54.     with any programs that are able to use IMG files.  They have been
  55.     tested with the IMG viewer from Migraph, IMG Quick View, WordUp,
  56.     PageStream and Easy-Draw as well as a program I wrote to use the
  57.     GEM function, v_bit_image(), to print IMG files with the help of
  58.     GDOS. (Or 'G+Plus' from CodeHead Software.)
  59.  
  60.     The program will work in any of the standard ST resolutions, although
  61.     a monochrome system is the ideal configuration.  I do not have access
  62.     to a large-screen display, but the program should work on large-screens
  63.     as well.
  64.  
  65.     Monochrome users will be able to view the conversion process for
  66.     color images.
  67.  
  68. File Type Buttons:
  69. ---- ---- -------
  70.  
  71.     The 'File Type Buttons' are labeled with the extension of the file
  72.     type expected when chosen.  The selection of a file type should be
  73.     done AFTER all desired options are selected.  Following the selection
  74.     of a file type, the File Selector will appear.  Unless the PATH
  75.     designator is changed, only the files with the appropriate extension
  76.     will be shown.  Choosing a file will begin the conversion.
  77.     There is NO checking in the program to insure that the correct file
  78.     type has been selected, so DON'T choose a file with the wrong
  79.     extension.
  80.  
  81.     [*.NEO] - Neochrome
  82.     [*.PI?] - DEGAS Uncompressed
  83.     [*.PC?] - DEGAS Compressed
  84.     [*.TN?] - Tiny
  85.     [*.ART] - Art Director
  86.     [*.DOO] - Doodle  (Public Painter will save in this format.)
  87.     [*.SPU] - Spectrum Uncompressed
  88.     [*.SPC] - Spectrum Compressed
  89.     [*.MAC] - Mac Paint
  90.     [*.IMG] - IMG (GEM Bit-images) *Monochrome images assumed.
  91.  
  92.     Following the execution of all the selected options, the user will
  93.     again be presented with the file selector to save the converted
  94.     image.
  95.  
  96.     Selection of [CANCEL] at ANY TIME from within the file selector will
  97.     return the user to the main dialog.
  98.  
  99. OPTIONS:
  100. -------
  101.  
  102.     [Save as *.PI3] - Selecting this option will allow the converted image
  103.                       to be saved as a DEGAS hi-res, uncompressed file.
  104.                       This is to allow editing with the many ST paint
  105.                       programs that support this format.  Testing shows
  106.                       that a converted image saved as DEGAS hi-res will
  107.                       convert very well to medium-res DEGAS with PicSwitch.
  108.                       For color systems, this is the best approach to
  109.                       additional editing.  The medium-res file can then be
  110.                       converted to IMG using 'Convert to IMG' with minimal
  111.                       loss of quality.
  112.  
  113.                       Mac Paint and IMG files, as well as Rotation and
  114.                       Clipping, ARE NOT available when this option is
  115.                       selected.  And visa-versa.
  116.  
  117.     [Clip Image]    - Selecting this option will open a window, following
  118.                       the image conversion and prior to Rotation, where
  119.                       the user can select a portion of the converted image
  120.                       to be saved.  The Clipping Window is explained below.
  121.  
  122.     [ROTATE]        - There are 4 buttons with Arrows that designate the
  123.                       direction that an image will be rotated if they are
  124.                       selected.  The default is the UP arrow.  Rotation
  125.                       is the last option executed by the program before
  126.                       allowing the user to save the image.  Depending on
  127.                       the size and dimensions of the image, rotation times
  128.                       will vary.
  129.  
  130.     [Manual Maker]  - Selecting this button will add 270 degrees to the
  131.                       rotation of the converted image.  A 270 degree
  132.                       rotation will be necessary to properly align a
  133.                       graphic image in future versions of Manual Maker.
  134.                       Think of the [Manual Maker] option as an extension
  135.                       of Rotation.
  136.  
  137.                       (This is the main reason this program was written.)
  138.  
  139.     [Info]          - Displays a dialog explaining that the program is
  140.                       ShareWare and giving information on where to send
  141.                       donation/questions.
  142.  
  143.     [Hold]          - *Only available on monochrome systems.  This will
  144.                       hold the converted image on the screen until the
  145.                       left button is pressed and released.  Some users
  146.                       of previous versions of this program requested this
  147.                       option to allow monochrome users to view color
  148.                       images.  (Particularily Spectrum.)
  149.  
  150.                       Not available for Mac and IMG formats.  Use the
  151.                       clipping window to view those file formats.
  152.  
  153.     [Exit]          - There is NO confirmation made on exit, the program
  154.                       will simply exit.  Pressing RETURN or ENTER will
  155.                       also cause the program to exit from the main dialog.
  156.  
  157. Clipping Window:
  158. -------- ------
  159.  
  160.     The clipping window uses custom cursor forms to indicate which corner
  161.     of the clip is being selected.  If the cursor leaves the visible
  162.     portion of the image, the cursor will resume the form of the Arrow.
  163.  
  164.     There are 2 custom forms.  The first that the user will see is the
  165.     cursor to indicate the Upper-Left corner.  This is 2 lines meeting
  166.     at an apex in the upper-left.  The characters 'U' and 'L' appear in
  167.     the cursor also.  The point selected when the mouse button is pressed
  168.     will be the point under the apex.  The sides of the cursor will lie on
  169.     the sides of the clip.
  170.  
  171.     After pressing the left mouse button, the cursor will change to indicate
  172.     selection of the Lower-Right corner.  This is similar to the Upper-Left
  173.     cursor, except the apex is in the lower-right and the characters in the
  174.     cursor are 'L' and 'R'.  The cursor will change back to the Upper-Left
  175.     form following the selection of a lower-right corner.
  176.  
  177.     Upon selection of a corner with either cursor, intersecting lines will
  178.     be draw indicating the sides of the selected clip.  The lines will
  179.     extend to the entire length and width of the image and the intersection
  180.     will indicate the corners.  (Lines may be visible when the image is
  181.     first shown because the Upper-Left will default to the upper-left of
  182.     the image and the Lower-Right to the lower-right of the image.)
  183.  
  184.     NOTE:   The designated corners will ALWAYS represent opposite corners
  185.             of the clip region whether or not the Lower-Right corner is in
  186.             the lower-right.  The same is true of the Upper-Left corner.
  187.  
  188.     Keys:
  189.     ----
  190.  
  191.     [Esc]       - The Escape key will toggle the cursor form.  If the user
  192.                   selects a corner and decides that it was not appropriate,
  193.                   they can toggle back to the appropriate cursor form by
  194.                   pressing this key and then select the corner again.
  195.  
  196.     [Undo]      - Resets the corners to the upper-left and lower-right of
  197.                   the entire image.
  198.  
  199.     [Insert]    - Resets the Lower-Right corner to that of the entire image.
  200.  
  201.     [Home]      - Resets the Upper-Left corner to that of the entire image.
  202.  
  203.  
  204.     Clicking on the CLOSE window button will exit the Clipping window and
  205.     cause the selected section to be 'clipped' and made available for
  206.     saving as an IMG file.
  207.  
  208. Version 1.10:
  209. ======= ====
  210.  
  211.     Version 1.10 corrects a minor problem related to Mac Paint files.  It
  212. seems the files I used in testing earlier versions were Mac Paint files
  213. that had been moved to an IBM and had had the MacBinary header stripped
  214. from the file.  This meant that when versions prior to 1.10 tried to read
  215. a Mac Paint file from a Mac, it would think there was no header.  I believe
  216. version 1.10 will correctly determine whether the file came from a Mac or
  217. other source and will now successfully load Mac Paint files from either.
  218. If a problem still exists or a problem appears in reading any of the other
  219. formats, please let me know.  Thank you.
  220.  
  221. PLEASE SEND COMMENTS:
  222. ====== ==== ========
  223.  
  224.     If there is something you would like to see added to this program,
  225. send me a message through GEnie or write to the address above.  My address
  226. on GEnie is: C.DAYMON.  If you have any information on any paint formats
  227. you would like to see added or detailed information on formats already
  228. supported, please get in touch with me.  (Not all the information I have
  229. is accurate and I have had to make an educated guess or two.)  I am
  230. especially looking for information on TIFF, IFF, Mac (all formats including
  231. those for the Mac II) and more information on Art Director.
  232.  
  233.     I am considering an accessory version of this program if the program
  234. receives enough support.  Also, faster clipping window updates and possibly
  235. some simple editing tools (particularily a WHITE fill) are being considered.
  236.  
  237. The IMG file format (a DETAILED description)
  238. === === ==== ====== ========================
  239.  
  240.     The first part of any .IMG file is the header.  (Sounds reasonable.)
  241. Each item in the header is a 16-bit word.
  242.  
  243. The format is:
  244.  
  245.     Word    |   Contents
  246. =============================================================================
  247.      0      |   IMG version number.  ( 0x0001 works best, believe me. )
  248.      1      |   Header length in words.  ( IMPORTANT to check when reading. )
  249.      2      |   Number of bit planes. ( Also IMPORTANT.  1 = Monochrome. )
  250.      3      |   Pattern length.     ( Part of data compression, usually 2. )
  251.      4      |   Source device pixel width in microns. (25,400 microns/inch)
  252.      5      |   Source device pixel height in microns.
  253.      6      |   Number of pixels per scan line.
  254.      7      |   Number of scan lines.
  255.  
  256. Notes:
  257. =====
  258.  
  259.     1)  I use a value of 8 for the header length as do most of the
  260.         monochrome images available.  (No extra information.)
  261.     2)  The number of bit planes designates the number of colors available.
  262.         1 = Monochrome (1 bit, 2 colors), 2 = Medium Res. (2 bits, 4 colors),
  263.         4 = Low Res. (4 bits, 16 colors)
  264.     3)  The number of bit planes is also important in that an IMG file
  265.         saves ALL the information for the first bit plane before saving the
  266.         information for the second and so on...
  267.     4)  The source pixel width and height are primarily used for
  268.         determining the aspect ratio of an image. (Personal opinion.)
  269.         The 'work_out[]' array used by GEM returns the pixel width and
  270.         height for a specified device from the function, v_opnwk() in
  271.         words 3 and 4.  In the case of the screen, I don't believe these
  272.         values are accurate for size, but they do properly indicate the
  273.         correct aspect ratio.  The ST monochrome screen "device" will return
  274.         the value 372 in both words 3 and 4, indicating a 1:1 aspect ratio.
  275.         DO NOT change IMG header words 4 and 5 to be some 'printer' specific
  276.         setting!  This is WRONG!  The GDOS printer drivers already KNOW the
  277.         size of a printer pixel and expect these header values to tell it
  278.         what size the pixel was on the device that CREATED the IMG file.
  279.     5)  Atari markets a product in europe called, HyperPaint, that can
  280.         edit and save IMG images.  It extends the header by 17 words to
  281.         hold the current palette.  (Or so I'm told.)  Unfortunately,
  282.         there is no predefined way to tell WHAT extra information may be
  283.         stored in an IMG file.  It is up to the program that created the
  284.         file and therefore, extra information is often of little use.
  285.         Other programs using the IMG format store the palette in separate
  286.         files.
  287.  
  288. The Bit-Map
  289. === === ===
  290.  
  291.     IMG files are stored a scan-line at a time using one of three methods.
  292. A scan-line can use more than one method of compression, but the compression
  293. cannot extend to data of the next scan-line.  (REMEMBER: All the scan lines
  294. for bit plane 0 are stored, followed by bit plane 1 and so on.)
  295. The 3 methods are BIT STRING, PATTERN RUN and SOLID RUN.
  296.  
  297. NOTE:
  298. ====
  299.  
  300.     The following description is written as if the file is being READ
  301. and the program is trying to uncompress the image.
  302.  
  303.     BIT STRING:
  304.     === ======
  305.  
  306.         This is the one I use, it's the easiest.  (It's also the least
  307.         efficient since it incorporates NO compression.)
  308.  
  309.     Byte 0    :     0x80    -   Specifies a Bit String.
  310.                                 (A number of bytes to be read "as is".)
  311.     Byte 1    :     0-255   -   Number of bytes in Bit String.
  312.     Byte 2,...:             -   No more than a scan-line's worth of raw
  313.                                 data for the bit plane being saved.
  314.  
  315.     SOLID RUN:
  316.     ===== ===
  317.  
  318.         A solid run means that ALL the bits in the block are either
  319.     on or off.  It is specified by a single byte whose high-order bit is
  320.     set to indicate ON or OFF.  The lower seven bits specify the number of
  321.     bytes making up the run with all their bits set or cleared.
  322.     Thus, up to 127 bytes can make up a block using this method.
  323.  
  324.     Example:
  325.     -------
  326.         Byte = 0x03 = 00000011
  327.  
  328.         Results in 3 bytes with NO bits set.
  329.  
  330.             00000000 00000000 00000000      (Resulting Bit Pattern.)
  331.  
  332.     PATTERN RUN:
  333.     ======= ===
  334.  
  335.         A pattern run is a number of 'pattern bytes' repeated a specified
  336.     number of times.  The number of bytes making up a pattern is specified
  337.     in Word 3 of the Header.  (Usually 2.)
  338.  
  339.     There are 2 bytes + the "pattern bytes" in a pattern run.
  340.  
  341.     Byte 0      :   0x00    -   Specifies a pattern run.  (Mostly)
  342.     Byte 1      :   1-255   -   Number of times to repeat the pattern.
  343.     Byte 2,...  :           -   Pattern to be repeated.
  344.  
  345.  
  346.     *REPLICATION COUNT:
  347.      =========== =====
  348.  
  349.         A scan-lines worth of data can be repeated up to 255 times by
  350.     preceeding any one of the 3 previous methods with a replication
  351.     count.  A replication count consists of 4 bytes.  The Repeat Count
  352.     should come right BEFORE any of the data for the scan-line to be
  353.     repeated.
  354.  
  355.     Byte 0      :   0x00    -   (A sort-of large pattern run.)
  356.     Byte 1      :   0x00    -   To avoid confusion with a pattern run.
  357.     Byte 2      :   0xFF    -   ??? (I don't know why.)
  358.     Byte 3      :   0-255   -   Number of times to repeat scan-line data.
  359.  
  360. Comments:
  361. ========
  362.  
  363.     The different compression techniques CAN be mixed in a single scan-line,
  364. but cannot extend beyond a single scan-line.  This is because the scan-line
  365. might not end on a byte boundary.  (Width not divisible by 8.)
  366.  
  367.     This information was extracted from 2 articles appearing in recent
  368. british ST magazines.
  369.  
  370.         June 1989 Atari ST User :   Page 117
  371.         July 1989 ST World (UK) :   Page 48
  372.  
  373.     If you are interested in the IMG format, try to get either or both
  374. of these magazines.  The first discusses IMG relative to the program
  375. listing in the article, but is still rather complete.  The second is
  376. entirely oriented to describing the IMG format.
  377.  
  378.     I guess it wasn't so short after all.  Let me know any features you
  379. would like to see added to the program.
  380.  
  381. -Craig W. Daymon
  382.  
  383.  
  384. P.S.  A version of this program will be included as part of the commercial
  385.       version of Manual Maker.
  386.  
  387.