home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / PCXDISP.ZIP / PCXDISP.DOC < prev    next >
Encoding:
Text File  |  1992-07-16  |  8.4 KB  |  184 lines

  1. PCXDISP.BAS
  2. By: Troy J. Ness
  3. Written: 6/15/92
  4.  
  5. DISCLAIMER:
  6.  
  7. The lawyers run the world so I have to say this. The code, programs, and 
  8. information included with this file have no warranties. You use these at
  9. your own free will and at your own risk. Opening any of these files means
  10. that you release me from any liabilty of damage caused to any hardware or
  11. software. If you do not agree to these terms stop here and delete all of
  12. these files.
  13.  
  14. I starting playing around with graphic and notice that they where all done in
  15. C, Pascal, or Asembly. I had done some work for my company in BASIC. We had
  16. some old programs that we could not do without. I wondered if graphics files
  17. could be shown in BASIC. I set out to find some information. Well, as you
  18. probably know they are all in C or Assembly.
  19.  
  20. I found a book called Bit-Mapped Graphics by Steve Rimmer. A pretty good 
  21. book, but Steve has a tendency to say "Well, If you don't understand, just 
  22. look at the source code." Great, if you are a C guru?! In all fairness the 
  23. book did help, but I will have to learn C to take full advantage of it.
  24.  
  25. The real break came when I was going through the QuickBASIC Newsletter, a
  26. great source of information, and came across some source code that was sent
  27. in by G.C. Harder. He had re-engineered some code from "Fractial Programming 
  28. in C." It drew the DEMO.PCX that is included with this file, saved it and
  29. then display it. Great, Right? Well, it is not over yet. G.C. did not put
  30. any comments in the code and it would only display a file in orginally
  31. drawn in screen 9 and it had to be a full screen file.
  32.  
  33. This causes problems because windows save PCX file in screen 12 640 x 480
  34. on a VGA system, which is what I had. Plus, I only want to diplay and use
  35. a little fragment of the screen. So, between what Rimmer wrote and Harder
  36. had done, I came up with this routine for opening and diplaying PCX files.
  37.  
  38. The PCXDISP.EXE is easy to use. At the prompt type PCXDISP [filename].
  39. First, it will show you the header information in a crude way, but it is
  40. nice to study. Then press enter to diplay the file. It is not really fast
  41. because it is written totally in QuickBASIC. It will work in the
  42. interperter QBASIC but, you can't use the COMMAND$ function. You will
  43. have to replace it with an INPUT statement. It is a turtle in QBASIC.
  44.  
  45. I will explain a little about the PCX file. When I have used "PCX file" ,
  46. I mean 640 x 350 x 16 colors (SCREEN 9) or 640 x 480 x 16 colors (SCREEN 12)
  47. and only those two. In other formats are similar but, are different in 
  48. dealing with the pallette. 
  49.  
  50. THE HEADER: It is the first 128 bytes of the file and is discribed below...
  51.  
  52. Discription                   Size      Comments
  53. ============================================================================
  54. Manufacturer (an idenifier)   Byte      Always &HA0 for .PCX file
  55.  
  56. Version Idenifier             Byte      Ver 2.5 = 0, Ver 2.8 with vaid 
  57.                                         palette = 2, Ver 2.8 without palette 
  58.                                         (either monochrome or will use default
  59.                                         palette.) = 3, Ver 3 on up = 5.
  60.  
  61. Encoding                      Byte      Always 1, only run length encoding
  62.                                         used.
  63.  
  64. Bits per pixel                Byte      Tells how bits are required to
  65.                                         display one pixel.
  66.  
  67. Xmin, Ymin                    Word ea.  Usually zero. Remember left corner is
  68.                                         0,0.
  69.  
  70. Xmax, Ymax                    Word ea.  Xmax for full screen is 639, Ymax for
  71.                                         screen 9 is 349 and 479 for screen 12.
  72.  
  73. Horizonal Resolution          Word      Give the resolution for the monitor
  74.                                         on which the picture was created.
  75.  
  76. Vertical Resolution           Word      Same as above.
  77.  
  78. Palette(48)                   Bytes     An array of 48 bytes. 3 bytes for
  79.                                         each color. The 1 of 3 gives the 
  80.                                         intensity of red, 2 of 3 gives blue,
  81.                                         3 of 3 gives green. If one color is
  82.                                         black then that color in the palette
  83.                                         has 0,0,0 for its bytes. If it is 
  84.                                         red then it is 255,0,0 for it's bytes.
  85.                                         All color in between these 3 basics
  86.                                         are additive.
  87.  
  88. Reserved (not used)           Byte      
  89.  
  90. Color Planes                  Byte      Gives the number of color planes. It
  91.                                         has to do with how your video card
  92.                                         handles the buffers.
  93.  
  94. Bytes per line                Word      Gives the number of bytes needed to 
  95.                                         display an entire line. It varies 
  96.                                         depending on the width of the
  97.                                         picture.
  98.  
  99. Palette Type                  Word      Only meaningful if you need to do
  100.                                         gray scales. I don't know much else
  101.                                         about it. It is 1 for gray scales
  102.                                         and 2 for full color.
  103.  
  104. Filler(58) (not used)         Bytes     Last 58 bytes are not used.       
  105.  
  106. Some of this assume that you know something about how graphics and colors
  107. are handled but, your monitor and card. Your QuickBASIC 4.5 manual talk a
  108. little about plane and how bits determine whether a pixel is off or on.
  109.  
  110. ENCODING AND DECODING: The PCX file is pack so you must unpack it the
  111. algorythm is discribed below.
  112.  
  113. 1    Read a byte from the file.
  114. 2    If 2 high bits are set then
  115.           INDEX equals (byte AND &H3F)
  116.           Read another byte from the file
  117.           Write the byte INDEX times
  118.      Else
  119.           Write the byte
  120. 3    If the whole line is unpacked then
  121.           Goto STOP
  122.      Else
  123.           Goto 1
  124.  
  125. If none of this makes any sense then I would suggest some other reading.
  126.  
  127. QuickBAIC Newsletter: I have only seen the first two volumes, and I think
  128. that is it. It has some of the best basic information that I have seen.
  129. You can pick it up probably on Compuserve and I do know it is on America
  130. Online. It may be found on your local BBS or these below.
  131.  
  132.          Name           Sysop       Location       Number         Node #
  133.      ---------------------------------------------------------------------
  134.      
  135.      Treasure Island  Don Dawson    Danbury, CT    203-791-8532   1:141/730
  136.      
  137.      Gulf Coast BBS   Jim Brewer New PortRichey,FL 904-563-2547   1:365/12
  138.      
  139.      221B Baker St.   James Young   Panama City,FL 904-871-6536   1:3608/1
  140.      
  141.      EMC/80           Jim Harre     St. Louis, MO  314-843-0001   1:100/555
  142.      
  143.      Apple Capitol BBS Bob Finley   Wenatchee, WA  509-663-3618   1:344/61
  144.      
  145.      
  146.           And maybe from these vendors BBS's:
  147.      
  148.      The Crescent Software Support BBS   203-426-5958
  149.      
  150.      The EllTech Support BBS             404-928-7111
  151.      
  152.      The Microhelp BUG BBS               404-552-0567
  153.                                          404-594-9625
  154.      
  155.      
  156.      You do not have to be a customer of these vendors in order to download
  157.      The  QBNews, but the Microhelp BBS only allows non-members 15  minutes
  158.      of time per call.
  159.  
  160. If you can not find it in any of these places then you can try to get a hold
  161. of me and will send you the complete two volumes for $5 that include S/H and
  162. a disk. It is about 700k to 800k depending on the type of compression you
  163. want. Plus, I will put any other good stuff that I have found just to fill up
  164. the disk. Make sure you tell me what type of compression, and the size of 
  165. disk you what.
  166.  
  167. Don't send disk to me, it will still be $5. This is to cover the fee of
  168. shipping, packaging, disk(s), and my time. It does not give any rights to
  169. the licence of any software contained in the files. You must follow the terms 
  170. set forth by the authors.
  171.  
  172. I will be in Utah for the next few years and you can reach me at.
  173.  
  174. Troy J. Ness
  175. 225 N. 1000 E.
  176. Orem, UT 84057
  177.  
  178. Or, on America Online as Troy500.
  179.  
  180. If you have any questions drop me a postcard or E-Mail.
  181.  
  182. Steve Rimmer book is published by Windcrest books. He has a new book out
  183. called Supercharged Bit-Mapped Graphics.
  184.