www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/07/04:39:48

From: "Gautam N. Lad" <gautam AT interlog DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Help with this PCX displaying source (in DJGPP & GRX)
Date: 7 Feb 1997 02:25:21 GMT
Organization: InterLog Internet Services
Lines: 134
Message-ID: <5de3qh$egn@news.interlog.com>
NNTP-Posting-Host: ip220-205.cc.interlog.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
Can someome please help me with this PCX displaying source.  It
works for one image, a friend sent, but others don't work.  WHY?
It seems right to me.

I've been looking for a PCX displaying source in DJGPP & GRX
and now that I have it, it doesn't work.

NOTE:  I won't be using 320x200 images only.  I might be using a 
       smaller size.

Here's the source.  PLEASE HELP!

//*******************************************************************
//
//  PCX.C
//  PCX Displaying source in DJGPP v2.0 and GRX v2.0
//  Author: Gautam N. Lad
//  E-Mail: gautam AT interlog DOT com
//
//*******************************************************************
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <conio.h>
#include <grx20.h>
#include <dos.h>
#include <float.h>
#include <fcntl.h>
#include <io.h>

/////////////////// DEFINES ///////////////////////

#define BYTE 			unsigned char
#define MAX_COLORS		256
#define COMPRESSED_CODE 0xC0

int IMAGE_WIDTH = 320;
int IMAGE_HEIGHT = 200;


typedef struct
{
    BYTE red;
    BYTE green;
    BYTE blue;
} COLOR;

typedef COLOR PALETTE[MAX_COLORS];


void GetPalette(char* strFileName, PALETTE Palette);
char buf[20];
GrMouseEvent evt;

void main()
{
	PALETTE Palette;
        GrSetMode(GR_width_height_color_graphics,640,480,65536);
        GrClearScreen(GrWhite());
        GetPalette("BALL.PCX",Palette);

}

void GetPalette(char* strFileName, PALETTE Palette)
{
    int a;
	BYTE color,count;
	int File,color_index,x,y;
        int color_map[MAX_COLORS];
	File=open(strFileName,O_RDONLY);


    if(File == -1)
		return;

	lseek(File,-768,SEEK_END);

	for(color_index=0;color_index < MAX_COLORS; color_index++)
	{

        read(File,&Palette[color_index].red,1);

        read(File,&Palette[color_index].green,1);

        read(File,&Palette[color_index].blue,1);

        color_map[color_index] = GrAllocColor(Palette[color_index].red,
                                              Palette[color_index].green,
                                              Palette[color_index].blue);
	}

	lseek(File,128,SEEK_SET);

	x=y=0;

	do
	{
		read(File,&color,1);

		if (color > COMPRESSED_CODE)
		{
			count = color-COMPRESSED_CODE;
			read(File,&color,1);
		}
        else { count = 1; }

        while(count-- > 0)
		{
          GrPlot(x++,y,color_map[color]);
            if(x >= IMAGE_WIDTH)
			{
	                x=0;
			y++;
			}
		}
    } while(y < IMAGE_HEIGHT);

	close(File);
}
//*****************E N D   O F   F I L E*****************************


****************************************************
* Gautam N. Lad                                    *
*--------------------------------------------------*
*                                                  *
* E-Mail	: gautam AT interlog DOT com              *
* Website	: http://www.interlog.com/~gautam  *
*                                                  *
* OS/2, DOS/Windows, Graphics Gallery, Software,   *
* Links, Rayzor Editor/2, POV-Ray,  and more.      *
****************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019