Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


PCX question. C in dos


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   -  Reputation:

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


Sponsor:

#2 Jim Adams   Members   -  Reputation: 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.



PARTNERS