home *** CD-ROM | disk | FTP | other *** search
- PCXDISP.BAS
- By: Troy J. Ness
- Written: 6/15/92
-
- DISCLAIMER:
-
- The lawyers run the world so I have to say this. The code, programs, and
- information included with this file have no warranties. You use these at
- your own free will and at your own risk. Opening any of these files means
- that you release me from any liabilty of damage caused to any hardware or
- software. If you do not agree to these terms stop here and delete all of
- these files.
-
- I starting playing around with graphic and notice that they where all done in
- C, Pascal, or Asembly. I had done some work for my company in BASIC. We had
- some old programs that we could not do without. I wondered if graphics files
- could be shown in BASIC. I set out to find some information. Well, as you
- probably know they are all in C or Assembly.
-
- I found a book called Bit-Mapped Graphics by Steve Rimmer. A pretty good
- book, but Steve has a tendency to say "Well, If you don't understand, just
- look at the source code." Great, if you are a C guru?! In all fairness the
- book did help, but I will have to learn C to take full advantage of it.
-
- The real break came when I was going through the QuickBASIC Newsletter, a
- great source of information, and came across some source code that was sent
- in by G.C. Harder. He had re-engineered some code from "Fractial Programming
- in C." It drew the DEMO.PCX that is included with this file, saved it and
- then display it. Great, Right? Well, it is not over yet. G.C. did not put
- any comments in the code and it would only display a file in orginally
- drawn in screen 9 and it had to be a full screen file.
-
- This causes problems because windows save PCX file in screen 12 640 x 480
- on a VGA system, which is what I had. Plus, I only want to diplay and use
- a little fragment of the screen. So, between what Rimmer wrote and Harder
- had done, I came up with this routine for opening and diplaying PCX files.
-
- The PCXDISP.EXE is easy to use. At the prompt type PCXDISP [filename].
- First, it will show you the header information in a crude way, but it is
- nice to study. Then press enter to diplay the file. It is not really fast
- because it is written totally in QuickBASIC. It will work in the
- interperter QBASIC but, you can't use the COMMAND$ function. You will
- have to replace it with an INPUT statement. It is a turtle in QBASIC.
-
- I will explain a little about the PCX file. When I have used "PCX file" ,
- I mean 640 x 350 x 16 colors (SCREEN 9) or 640 x 480 x 16 colors (SCREEN 12)
- and only those two. In other formats are similar but, are different in
- dealing with the pallette.
-
- THE HEADER: It is the first 128 bytes of the file and is discribed below...
-
- Discription Size Comments
- ============================================================================
- Manufacturer (an idenifier) Byte Always &HA0 for .PCX file
-
- Version Idenifier Byte Ver 2.5 = 0, Ver 2.8 with vaid
- palette = 2, Ver 2.8 without palette
- (either monochrome or will use default
- palette.) = 3, Ver 3 on up = 5.
-
- Encoding Byte Always 1, only run length encoding
- used.
-
- Bits per pixel Byte Tells how bits are required to
- display one pixel.
-
- Xmin, Ymin Word ea. Usually zero. Remember left corner is
- 0,0.
-
- Xmax, Ymax Word ea. Xmax for full screen is 639, Ymax for
- screen 9 is 349 and 479 for screen 12.
-
- Horizonal Resolution Word Give the resolution for the monitor
- on which the picture was created.
-
- Vertical Resolution Word Same as above.
-
- Palette(48) Bytes An array of 48 bytes. 3 bytes for
- each color. The 1 of 3 gives the
- intensity of red, 2 of 3 gives blue,
- 3 of 3 gives green. If one color is
- black then that color in the palette
- has 0,0,0 for its bytes. If it is
- red then it is 255,0,0 for it's bytes.
- All color in between these 3 basics
- are additive.
-
- Reserved (not used) Byte
-
- Color Planes Byte Gives the number of color planes. It
- has to do with how your video card
- handles the buffers.
-
- Bytes per line Word Gives the number of bytes needed to
- display an entire line. It varies
- depending on the width of the
- picture.
-
- Palette Type Word Only meaningful if you need to do
- gray scales. I don't know much else
- about it. It is 1 for gray scales
- and 2 for full color.
-
- Filler(58) (not used) Bytes Last 58 bytes are not used.
-
- Some of this assume that you know something about how graphics and colors
- are handled but, your monitor and card. Your QuickBASIC 4.5 manual talk a
- little about plane and how bits determine whether a pixel is off or on.
-
- ENCODING AND DECODING: The PCX file is pack so you must unpack it the
- algorythm is discribed below.
-
- 1 Read a byte from the file.
- 2 If 2 high bits are set then
- INDEX equals (byte AND &H3F)
- Read another byte from the file
- Write the byte INDEX times
- Else
- Write the byte
- 3 If the whole line is unpacked then
- Goto STOP
- Else
- Goto 1
-
- If none of this makes any sense then I would suggest some other reading.
-
- QuickBAIC Newsletter: I have only seen the first two volumes, and I think
- that is it. It has some of the best basic information that I have seen.
- You can pick it up probably on Compuserve and I do know it is on America
- Online. It may be found on your local BBS or these below.
-
- Name Sysop Location Number Node #
- ---------------------------------------------------------------------
-
- Treasure Island Don Dawson Danbury, CT 203-791-8532 1:141/730
-
- Gulf Coast BBS Jim Brewer New PortRichey,FL 904-563-2547 1:365/12
-
- 221B Baker St. James Young Panama City,FL 904-871-6536 1:3608/1
-
- EMC/80 Jim Harre St. Louis, MO 314-843-0001 1:100/555
-
- Apple Capitol BBS Bob Finley Wenatchee, WA 509-663-3618 1:344/61
-
-
- And maybe from these vendors BBS's:
-
- The Crescent Software Support BBS 203-426-5958
-
- The EllTech Support BBS 404-928-7111
-
- The Microhelp BUG BBS 404-552-0567
- 404-594-9625
-
-
- You do not have to be a customer of these vendors in order to download
- The QBNews, but the Microhelp BBS only allows non-members 15 minutes
- of time per call.
-
- If you can not find it in any of these places then you can try to get a hold
- of me and will send you the complete two volumes for $5 that include S/H and
- a disk. It is about 700k to 800k depending on the type of compression you
- want. Plus, I will put any other good stuff that I have found just to fill up
- the disk. Make sure you tell me what type of compression, and the size of
- disk you what.
-
- Don't send disk to me, it will still be $5. This is to cover the fee of
- shipping, packaging, disk(s), and my time. It does not give any rights to
- the licence of any software contained in the files. You must follow the terms
- set forth by the authors.
-
- I will be in Utah for the next few years and you can reach me at.
-
- Troy J. Ness
- 225 N. 1000 E.
- Orem, UT 84057
-
- Or, on America Online as Troy500.
-
- If you have any questions drop me a postcard or E-Mail.
-
- Steve Rimmer book is published by Windcrest books. He has a new book out
- called Supercharged Bit-Mapped Graphics.
-