Если я запускаю RGB2GIF как:
RGB2GIF(true, 1, "../tests/porsche.rgb", ExpNumOfColors, 320, 200);
, вывод будет похож на оригинальное изображение
, но когда я использую другой файл rgb:
RGB2GIF(true, 1, "D:\\rgb.yuv", ExpNumOfColors, 1280, 720);`
В файле GIF отсутствуют цвета.
Это относительно глобальной карты цветов?местная цветная карта?
static void SaveGif(GifByteType *OutputBuffer, int Width, int Height, int ExpColorMapSize, ColorMapObject *OutputColorMap){int i, Error;
GifFileType *GifFile;
GifByteType *Ptr = OutputBuffer;
/* Open stdout for the output file: */
gfile = fopen("D:\\out_my.gif", "wb+");
if ((GifFile = EGifOpen(gfile, writeGifData, &Error)) == NULL) {
PrintGifError(Error);
exit(EXIT_FAILURE);
}
if (EGifPutScreenDesc(GifFile,
Width, Height, ExpColorMapSize, 0,
OutputColorMap) == GIF_ERROR ||
EGifPutImageDesc(GifFile,
0, 0, Width, Height, false, OutputColorMap) ==
GIF_ERROR){
PrintGifError(Error);
printf("error\n");
exit(EXIT_FAILURE);
}
GifQprintf("\n%s: Image 1 at (%d, %d) [%dx%d]: ",
PROGRAM_NAME, GifFile->Image.Left, GifFile->Image.Top,
GifFile->Image.Width, GifFile->Image.Height);
for (i = 0; i < Height; i++) {
if (EGifPutLine(GifFile, Ptr, Width) == GIF_ERROR)
exit(EXIT_FAILURE);
GifQprintf("\b\b\b\b%-4d", Height - i - 1);
Ptr += Width;
}
printf("\n");
printf("close file\n");
if (EGifCloseFile(GifFile, &Error) == GIF_ERROR)
PrintGifError(Error);
fclose(gfile);
exit(EXIT_FAILURE);
}
static void RGB2GIF(bool OneFileFlag, int NumFiles, char *FileName, int
ExpNumOfColors, int Width, int Height)
{
int ColorMapSize;
GifByteType *RedBuffer = NULL, *GreenBuffer = NULL, *BlueBuffer = NULL,
*OutputBuffer = NULL;
ColorMapObject *OutputColorMap = NULL;
ColorMapSize = 1 << ExpNumOfColors;
if (NumFiles == 1) {
LoadRGB(FileName, OneFileFlag,
&RedBuffer, &GreenBuffer, &BlueBuffer, Width, Height);
}
else {
LoadRGB(NULL, OneFileFlag,
&RedBuffer, &GreenBuffer, &BlueBuffer, Width, Height);
}
if ((OutputColorMap = GifMakeMapObject(ColorMapSize, NULL)) == NULL ||
(OutputBuffer = (GifByteType *)malloc(Width * Height *
sizeof(GifByteType))) == NULL)
GIF_EXIT("Failed to allocate memory required, aborted.");
printf("GifQuantizeBuffer\n");
if (GifQuantizeBuffer(Width, Height, &ColorMapSize,
RedBuffer, GreenBuffer, BlueBuffer,
OutputBuffer, OutputColorMap->Colors) == GIF_ERROR)
exit(EXIT_FAILURE);
free((char *)RedBuffer);
free((char *)GreenBuffer);
free((char *)BlueBuffer);
SaveGif(OutputBuffer, Width, Height, ExpNumOfColors, OutputColorMap);
}