ONLINE PICTURE VIEWER
GrafCon-ST: Part II
Last month, Antic published Grafcon-ST, a program that converts ST pictures between resolutions (low, medium and high) and also converts ST pictures into the RLE (Run Length Encoded) format used by CompuServe for their online high-resolution graphics. The complete program was too long to print in one issue. The RLE File Viewer program and the medium resolution converter functions in this issue complete the GrafCon-ST program.
The four medium-resolution functions left out of GrafCon-ST last month are LOMED(), MEDLO(), MEDHI() and HIMED(). As the titles indicate, the purposes of these respective functions are to convert LOw to MEDium resolution, MEDium to LOw resolution, MEDium to HIgh resolution and HIgh to MEDium resolution.
For example, if you need to use the LOMED() (LOw to MEDium) function, insert the LOMED() section of code into the Grafcon ST listing where LOMED() was indicated as being left out last month. Then recompile the program.
Last month's original listing shows clearly where each additional function should be added. But remember, as explained in the July, 1986 GrafCon-ST article, you don't need to type in any of the resolution conversion functions that you aren't going to use.
RLE FILE VIEWER
GrafCon-ST allows you to convert your ST graphics pictures into RLE format for uploading to CompuServe. But what about using the RLE VIDTEX pictures afready online? This month's program will take the ASCII picture file downloaded from CompuServe (as explained in last month's VIDTEX Converter article) and convert it to any ST graphics file format.
To keep things simpler, this month's RLE File Viewer program is presented as a stand-alone application. You don't need to merge it into GrafCon-ST.
Make sure that your disk has a RLE ASCII file-which you have downloaded from CompuServe or created with GrafCon-ST, as explained in last month's articles. Then double-click on RLESEE.PRG. After the welcome box, you are asked to select a destination format for the picture. Click on either NEO, DEGAS, or DOODLE. Next, choose the RLE filename from the file selector box and click on OK. Either you will see the picture begin to appear, or you will see a box stating the ST doesn't think the file is a good RLE picture. While the picture is being drawn, you may press either mouse button to abort.
When finished, you will get a file selector box prompting you to choose or create a file to write the picture to. Then you are presented with an alert box asking if you want to draw another RLE image.
TYPING IN RLESEE
Listing 1, RLESEE.C, is the RLE file viewer program written in Alcyon C from Atari ST Developer's Kit. Type it in carefuily and save it to disk. Compile, assemble and link this program to apstart, with vdibind, aesbind, osbind, and libf following along behind. Next, Relmod the resulting .68K file into an executable .prg program and you're finished.
Those of you with MegaMax C can type it in, but you need to Malloc() the RAM needed for the screen and text buffer. Hippo-C Owners are also encouraged to try, but you'll need the Hippo XBIOS file available for downloading from the SIG*Atari ST Section on CompuServe.
At the top of the program we have a commented block for the program title and revision date. Below that are the #defines, which are included here to make the program a bit easier to read. Variable declarations are next, with string char definitions coming after.
Our main() routine gives a list of what to do. First, initialize() the application, then convert() a picture and repeat the process while(not finished). Eventually the application gets finished and will terminate().
The convert() function describes the steps needed to properly convert an RLE file to a graphics file. First, read_the_picture() into an internal buffer. The next line will let us select_parameters(), which here determines what type of display format the resulting picture gets written in. Next, make_picture() converts the RLE ASCII format into one of the three individual graphics formats.
The picture will be expanded to fill as much of the screen as possible, regardless of resolution. Eventually the conversion will be complete, and control will drop down to write_the_file(). Before this section ends, you are asked if you want to perform another conversion. Click on YES or NO.
The make_picture() routine first scans the file looking for the ESCAPE G H header RLE files need. If it doesn't find one, it assumes the file is not an RLE file and tells you so before it drops out. Otherwise, the RLE file has been found and control passes to draw_picture().
The draw_picture() function will scan through the ASCII RLE file, pulling out the pairs of black and white pixel amounts. Since we will be drawing, we set drawing to TRUE, page flip to the destination picture buffer, set row and column to zero and hide the mouse cursor.
To reconstruct the picture, while we are drawing, we get each pair of black and white values and put the values in blackdots and whitedots. In blackdots, reaching the end of the file is signified with the ESCAPE character. Then drawing is set to FALSE, showing we are finished. Otherwise the next two blocks of code operate identically, first on the black dots and then on the white. Let's examine just the blackdots routine.
To plot the black dots, which we do while we have blackdots and we are drawing, call plot()-passing in the row, column, and color of the dot desired. When the dot has been plotted, we decrement the count of blackdots and increment the column count to point at the next column to the right. Then we perform the end_of_line_check() which checks for the end of each column in turn and then points to the next row.
After plotting each black and white dot in this pair, and before we check for the next available pair; we check to see if either mouse button is pressed in the graf_mkstate() call. If either button has been pressed, the value in pressed will be greater then zero, so pressed can be considered TRUE and drawing will be set FALSE.
Finally read_the_picture() will read in the RLE ASCII file from disk and place it into a buffer. The function write_the_file() writes the converted graphics picture back to disk in the proper graphics format, and terminate() will properly close the application and exit back to the Desktop.
Listing 1: MEDIUM.C (not available)
ONLINE PICTURE VIEWER
Listing 1: RLESEE.C (not available)