Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

PCX question. C in dos

This topic is 6955 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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?


#include
#include

typedef unsigned char db;
typedef unsigned int dw;

int main(void)
{
db buffer[64000];
dw count=0;
db temp,index;
FILE *fp;
fp=fopen("pcx.pcx","rb");

fseek(fp,128,0);

count=0;
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;
}
}

fclose(fp);

fp=fopen("pcx.dat","wb");
for(count=0;count<64000;count++)
{
putc(buffer[count],fp);
}
fclose(fp);

return 1;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!