sghauri
08-09-2004, 06:53 PM
Hi all
I parsed a BMP file that contained a palette in C. I decoded the image data using the palette and wrote the new data to a new BMP file. Now the original file and the new file should ideally be same but the new image when displayed in a viewer seems to have lost many colours. Any idea why is it so? The routines that I am using for decoding are as below:
void writeImageData(FILE *FpBmp)
{
long i;
char index;
if(containsPalette==1)
{
for(i=0; i<(ImageDataEntries); i++)
{
index=ImageData[i];
fputc((WinColorTable[index].rgbBlue),FpBmp);
fputc((WinColorTable[index].rgbGreen),FpBmp);
fputc((WinColorTable[index].rgbRed),FpBmp);
}
}
else
{
for(i=0; i<(ImageDataEntries); i++)
{
fputc(ImageData[i],FpBmp);
}
}
fclose(FpBmp);
}
ImageData[] contains the image data from the original file in which the image data were merely codes that were basically index into the palette.
Thanks
Samie
I parsed a BMP file that contained a palette in C. I decoded the image data using the palette and wrote the new data to a new BMP file. Now the original file and the new file should ideally be same but the new image when displayed in a viewer seems to have lost many colours. Any idea why is it so? The routines that I am using for decoding are as below:
void writeImageData(FILE *FpBmp)
{
long i;
char index;
if(containsPalette==1)
{
for(i=0; i<(ImageDataEntries); i++)
{
index=ImageData[i];
fputc((WinColorTable[index].rgbBlue),FpBmp);
fputc((WinColorTable[index].rgbGreen),FpBmp);
fputc((WinColorTable[index].rgbRed),FpBmp);
}
}
else
{
for(i=0; i<(ImageDataEntries); i++)
{
fputc(ImageData[i],FpBmp);
}
}
fclose(FpBmp);
}
ImageData[] contains the image data from the original file in which the image data were merely codes that were basically index into the palette.
Thanks
Samie