-
-
- void taille_pcx(char * fichier, unsigned * largeur, unsigned * hauteur)
- {
- FILE * flot;
- unsigned width = 0, height = 0;
-
- flot = fopen(fichier,"rb");
- fseek(flot,8,SEEK_SET);
- fread(&width,2,1,flot);
- fread(&height,2,1,flot);
- width++;
- height++;
-
- *largeur = width;
- *hauteur = height;
-
- fclose(flot);
- }
-
- void charge_palette_pcx(char * fichier)
- { unsigned char pal[256][3];
- int i,j;
- FILE * flot;
-
- if(!(sauve_palette("palette.dat")))
- {
- printf("Erreur dans la sauvegarde de la palette.\n");
- exit(1);
- }
-
- flot = fopen(fichier,"rb");
- fseek(flot,-768L,SEEK_END);
- for(i = 0; i <256 ; i ++)
- {
- pal_rouge[i] = fgetc(flot)>>2;
- pal_vert[i] = fgetc(flot)>>2;
- pal_bleu[i] = fgetc(flot)>>2;
- }
- fclose(flot);
- applique_palette();
- }
-
- void charge_pcx(char * fichier, unsigned char * buffer, unsigned taille)
- {
- FILE * flot;
-
- unsigned long position;
- unsigned num;
- unsigned char ch;
-
- flot = fopen(fichier,"rb");
- fseek(flot,128,SEEK_SET);
-
- position=0;
- do
- {
- ch = fgetc(flot);
- if ((ch & 0xC0) == 0xC0)
- {
- num = ch & 0x3F;
- ch = fgetc(flot);
- while(num--)
- buffer[position++]=ch;
- }
- else
- buffer[position++]=ch;
- }
- while(position < (taille));
- fclose(flot);
- }
-
- void affiche_pcx_transparent(unsigned char * buffersource, unsigned char * bufferdest, unsigned width, unsigned height, unsigned X, unsigned Y)
- {
- int u, z;
- for (u=0; u<=height-1; u++)
- for (z=0; z<=width-1; z++)
- {
- if((int)buffersource[u*width+z] && ((table_mode.resolution_horizontale*(Y+u)+X+z) < (table_mode.resolution_horizontale*table_mode.resolution_verticale)) && ((X+z) < table_mode.resolution_horizontale))
- (unsigned char *)bufferdest[table_mode.resolution_horizontale*(Y+u)+X+z] = buffersource[u*width+z];
- }
- }
-
- void affiche_pcx(unsigned char * buffersource, unsigned char * bufferdest, unsigned width, unsigned height, unsigned X, unsigned Y)
- { int u, z;
- for (u=0; u<=height-1; u++)
- for (z=0; z<=width-1; z++)
- {
- if(((table_mode.resolution_horizontale*(Y+u)+X+z) < (table_mode.resolution_horizontale*table_mode.resolution_verticale)) && ((X+z) < table_mode.resolution_horizontale))
- (unsigned char *)bufferdest[table_mode.resolution_horizontale*(Y+u)+X+z] = buffersource[u*width+z];
- }
- }
void taille_pcx(char * fichier, unsigned * largeur, unsigned * hauteur)
{
FILE * flot;
unsigned width = 0, height = 0;
flot = fopen(fichier,"rb");
fseek(flot,8,SEEK_SET);
fread(&width,2,1,flot);
fread(&height,2,1,flot);
width++;
height++;
*largeur = width;
*hauteur = height;
fclose(flot);
}
void charge_palette_pcx(char * fichier)
{ unsigned char pal[256][3];
int i,j;
FILE * flot;
if(!(sauve_palette("palette.dat")))
{
printf("Erreur dans la sauvegarde de la palette.\n");
exit(1);
}
flot = fopen(fichier,"rb");
fseek(flot,-768L,SEEK_END);
for(i = 0; i <256 ; i ++)
{
pal_rouge[i] = fgetc(flot)>>2;
pal_vert[i] = fgetc(flot)>>2;
pal_bleu[i] = fgetc(flot)>>2;
}
fclose(flot);
applique_palette();
}
void charge_pcx(char * fichier, unsigned char * buffer, unsigned taille)
{
FILE * flot;
unsigned long position;
unsigned num;
unsigned char ch;
flot = fopen(fichier,"rb");
fseek(flot,128,SEEK_SET);
position=0;
do
{
ch = fgetc(flot);
if ((ch & 0xC0) == 0xC0)
{
num = ch & 0x3F;
ch = fgetc(flot);
while(num--)
buffer[position++]=ch;
}
else
buffer[position++]=ch;
}
while(position < (taille));
fclose(flot);
}
void affiche_pcx_transparent(unsigned char * buffersource, unsigned char * bufferdest, unsigned width, unsigned height, unsigned X, unsigned Y)
{
int u, z;
for (u=0; u<=height-1; u++)
for (z=0; z<=width-1; z++)
{
if((int)buffersource[u*width+z] && ((table_mode.resolution_horizontale*(Y+u)+X+z) < (table_mode.resolution_horizontale*table_mode.resolution_verticale)) && ((X+z) < table_mode.resolution_horizontale))
(unsigned char *)bufferdest[table_mode.resolution_horizontale*(Y+u)+X+z] = buffersource[u*width+z];
}
}
void affiche_pcx(unsigned char * buffersource, unsigned char * bufferdest, unsigned width, unsigned height, unsigned X, unsigned Y)
{ int u, z;
for (u=0; u<=height-1; u++)
for (z=0; z<=width-1; z++)
{
if(((table_mode.resolution_horizontale*(Y+u)+X+z) < (table_mode.resolution_horizontale*table_mode.resolution_verticale)) && ((X+z) < table_mode.resolution_horizontale))
(unsigned char *)bufferdest[table_mode.resolution_horizontale*(Y+u)+X+z] = buffersource[u*width+z];
}
}