Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

PCX question. C in dos

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 30 September 1999 - 02: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?


#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;
}


#2 Jim Adams   Members   

440
Like
Likes
Like

Posted 30 September 1999 - 02:26 PM

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





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.