typedef unsigned char db; int main(void) fseek(fp,128,0); count=0; fclose(fp); fp=fopen("pcx.dat","wb"); return 1;
#include
#include
typedef unsigned int dw;
{
db buffer[64000];
dw count=0;
db temp,index;
FILE *fp;
fp=fopen("pcx.pcx","rb");
while(count<64000)
{
index=getc(fp);
if(index > 192)
{
index-=192;
temp=getc(fp);
while(index>0)
{
buffer[count++]=temp;
index--;
}
}
else
{
buffer[count++]=index;
}
}
for(count=0;count<64000;count++)
{
putc(buffer[count],fp);
}
fclose(fp);
}
PCX question. C in dos
September 30, 1999 08:26 PM
i've created a program in turbo C++ that is supposed to get the main data from a pcx file and uncompress the rle values and save it as a dat file with just the pixel data and no palette or header. but it always crashes. could someone please help me figure out whats wrong with the source?
db buffer[64000];
I don't remember offhand, but I think TC had a problem with arrays this large nested in a function. That isn't the problem though.
---------------------------------
if(index > 192)
{
index-=192;
temp=getc(fp);
while(index>0)
{
buffer[count++]=temp;
index--;
}
}
else
{
buffer[count++]=index;
}
}
---------------------------------
change to:
if(index > 191)
{
index &= 63;
temp=getc(fp);
while(index>0)
{
buffer[count++]=temp;
index--;
}
}
else
{
buffer[count++]=index;
}
}
---------------------------------
That's all by memory, but see if that works.
------------------
Jim Adams
Co-Designer 'The Light Befallen'
tcm@pobox.com
http://www.lightbefallen.com
Jim Adams, Author"Programming Role-Playing Games with DirectX""Advanced Animation with DirectX""Programming Role-Playing Games with DirectX, 2nd Edition"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement