No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- Answered by: jur9103
Please leave any comments here within the
next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !
Nic;o)
Main Topics
Browse All Topics





by: jur9103Posted on 2002-09-17 at 15:10:46ID: 7286836
you have to create dib from pcx. ch.asp?pag e=6&s=grap hics
it's easy. first go to
http://www.wotsit.org/sear
and download pcx specification.
with help of this file is easy to load pcx to memory as dib.
i hope it helps.
//this code snapshot is from Quake2 source from ID Software
//you can download full from ID ftp.
void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
{
byte *raw;
pcx_t *pcx;
int x, y;
int len;
int dataByte, runLength;
byte *out, *pix;
*pic = NULL;
//
// load the file
//
len = FS_LoadFile (filename, (void **)&raw);
if (!raw)
return; // Com_Printf ("Bad pcx file %s\n", filename);
//
// parse the PCX file
//
pcx = (pcx_t *)raw;
raw = &pcx->data;
if (pcx->manufacturer != 0x0a
|| pcx->version != 5
|| pcx->encoding != 1
|| pcx->bits_per_pixel != 8
|| pcx->xmax >= 640
|| pcx->ymax >= 480)
{
Com_Printf ("Bad pcx file %s\n", filename);
return;
}
out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
*pic = out;
pix = out;
if (palette)
{
*palette = Z_Malloc(768);
memcpy (*palette, (byte *)pcx + len - 768, 768);
}
if (width)
*width = pcx->xmax+1;
if (height)
*height = pcx->ymax+1;
for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
{
for (x=0 ; x<=pcx->xmax ; )
{
dataByte = *raw++;
if((dataByte & 0xC0) == 0xC0)
{
runLength = dataByte & 0x3F;
dataByte = *raw++;
}
else
runLength = 1;
while(runLength-- > 0)
pix[x++] = dataByte;
}
}
if ( raw - (byte *)pcx > len)
{
Com_Printf ("PCX file %s was malformed", filename);
Z_Free (*pic);
*pic = NULL;
}
FS_FreeFile (pcx);
}