harraken
Messages postés4Date d'inscriptionlundi 10 mars 2003StatutMembreDernière intervention 2 mai 2005 3 déc. 2005 à 22:42
je confirme ca ne marche absolument pas !!
k1roux
Messages postés4Date d'inscriptionmercredi 13 avril 2005StatutMembreDernière intervention 9 juin 2005 9 juin 2005 à 11:11
Salut, j'ai teste ce programme et il ne marche pas entierement, en effet, mon image originale est une image bitmap de 2.25 Mo, je compresse et j'obtiens une image de 1.52 Mo. Pour le moment, cela est correct, cependant lors de la decompression, je n'obtients l'image de depart, mais une image de 4.20 Mo qui ne ressemble a rien. Je n'arrive pas a resoudre mon probleme, si quelqu'un pouvait m'aider, merci.
3 déc. 2005 à 22:42
9 juin 2005 à 11:11
#include "stdafx.h"
#include <stdio.h>
#include
#include <tchar.h>
#include <conio.h>
FILE *entre,*sortie,*sortie_new;
unsigned char codeRepet=255,nbreRepet=1;
unsigned char AncCaract,caract,codeARepeter;
void compress(void)
{
fread(&AncCaract,sizeof(char),1,entre);
while (!feof(entre))
{
fread(&caract,sizeof(char),1,entre);
if (caract==AncCaract)
/*{
if (nbreRepet==253)
{
fwrite(&codeRepet,sizeof(char),1,sortie);
fwrite(&nbreRepet,sizeof(char),1,sortie);
fwrite(&AncCaract,sizeof(char),1,sortie);
nbreRepet = 1;
}
else nbreRepet++;
}*/
nbreRepet=nbreRepet+1;
else
{
if (nbreRepet>3)
{
fwrite(&codeRepet,sizeof(char),1,sortie);
fwrite(&nbreRepet,sizeof(char),1,sortie);
fwrite(&AncCaract,sizeof(char),1,sortie);
}
else
{
for (short i=0 ; i != nbreRepet ; i++)
{
fwrite(&AncCaract,sizeof(char),1,sortie);
}
}
nbreRepet = 1;
AncCaract = caract;
}
}
printf("Compression acheve");
}
void dcompress_new(void)
{
while (!feof(sortie))
{
fread(&caract,sizeof(char),1,sortie);
if (caract == codeRepet)
{
fread(&nbreRepet,sizeof(char),1,sortie);
fread(&codeARepeter,sizeof(char),1,sortie);
for (short i=0 ; i != nbreRepet ; i++)
{
fwrite(&codeARepeter,sizeof(char),1,sortie_new);
}
}
else
{
fwrite(&caract,sizeof(char),1,sortie_new);
}
}
printf("\nDecompression acheve");
}
int _tmain(int argc,char *argv[])
{
entre = fopen("d:\\ImAComp.bmp","rb");
sortie = fopen("d:\\ImComp.bmp","wb");
compress();
fclose(entre);
fclose(sortie);
sortie = fopen("d:\\ImComp.bmp","rb");
sortie_new = fopen("d:\\ImDecomp.bmp","wb");
dcompress_new();
fclose(sortie);
fclose(sortie_new);
getch();
return 0;
}
19 janv. 2003 à 14:49