Commit cfdf84b4 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Add support for color table sort flag to the GIF decoder.

parent ec206a84
...@@ -912,7 +912,8 @@ static HRESULT create_IMD_metadata_reader(GifFrameDecode *This, IWICMetadataRead ...@@ -912,7 +912,8 @@ static HRESULT create_IMD_metadata_reader(GifFrameDecode *This, IWICMetadataRead
IMD_data.packed |= 1 << 7; IMD_data.packed |= 1 << 7;
/* local_color_table_size */ /* local_color_table_size */
IMD_data.packed |= This->frame->ImageDesc.ColorMap->BitsPerPixel - 1; IMD_data.packed |= This->frame->ImageDesc.ColorMap->BitsPerPixel - 1;
/* FIXME: sort_flag */ /* sort_flag */
IMD_data.packed |= This->frame->ImageDesc.ColorMap->SortFlag ? 0x20 : 0;
} }
stream = create_stream(&IMD_data, sizeof(IMD_data)); stream = create_stream(&IMD_data, sizeof(IMD_data));
......
...@@ -272,7 +272,7 @@ FreeSavedImages(GifFileType * GifFile) { ...@@ -272,7 +272,7 @@ FreeSavedImages(GifFileType * GifFile) {
static int static int
DGifGetScreenDesc(GifFileType * GifFile) { DGifGetScreenDesc(GifFileType * GifFile) {
int i, BitsPerPixel; int i, BitsPerPixel, SortFlag;
GifByteType Buf[3]; GifByteType Buf[3];
/* Put the screen descriptor into the file: */ /* Put the screen descriptor into the file: */
...@@ -284,6 +284,7 @@ DGifGetScreenDesc(GifFileType * GifFile) { ...@@ -284,6 +284,7 @@ DGifGetScreenDesc(GifFileType * GifFile) {
return GIF_ERROR; return GIF_ERROR;
} }
GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1; GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
SortFlag = (Buf[0] & 0x08) != 0;
BitsPerPixel = (Buf[0] & 0x07) + 1; BitsPerPixel = (Buf[0] & 0x07) + 1;
GifFile->SBackGroundColor = Buf[1]; GifFile->SBackGroundColor = Buf[1];
GifFile->SAspectRatio = Buf[2]; GifFile->SAspectRatio = Buf[2];
...@@ -295,6 +296,7 @@ DGifGetScreenDesc(GifFileType * GifFile) { ...@@ -295,6 +296,7 @@ DGifGetScreenDesc(GifFileType * GifFile) {
} }
/* Get the global color map: */ /* Get the global color map: */
GifFile->SColorMap->SortFlag = SortFlag;
for (i = 0; i < GifFile->SColorMap->ColorCount; i++) { for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
if (READ(GifFile, Buf, 3) != 3) { if (READ(GifFile, Buf, 3) != 3) {
FreeMapObject(GifFile->SColorMap); FreeMapObject(GifFile->SColorMap);
...@@ -353,7 +355,7 @@ DGifGetRecordType(GifFileType * GifFile, ...@@ -353,7 +355,7 @@ DGifGetRecordType(GifFileType * GifFile,
static int static int
DGifGetImageDesc(GifFileType * GifFile) { DGifGetImageDesc(GifFileType * GifFile) {
int i, BitsPerPixel; int i, BitsPerPixel, SortFlag;
GifByteType Buf[3]; GifByteType Buf[3];
GifFilePrivateType *Private = GifFile->Private; GifFilePrivateType *Private = GifFile->Private;
SavedImage *sp; SavedImage *sp;
...@@ -367,6 +369,7 @@ DGifGetImageDesc(GifFileType * GifFile) { ...@@ -367,6 +369,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
return GIF_ERROR; return GIF_ERROR;
} }
BitsPerPixel = (Buf[0] & 0x07) + 1; BitsPerPixel = (Buf[0] & 0x07) + 1;
SortFlag = (Buf[0] & 0x20) != 0;
GifFile->Image.Interlace = (Buf[0] & 0x40); GifFile->Image.Interlace = (Buf[0] & 0x40);
if (Buf[0] & 0x80) { /* Does this image have local color map? */ if (Buf[0] & 0x80) { /* Does this image have local color map? */
...@@ -381,6 +384,7 @@ DGifGetImageDesc(GifFileType * GifFile) { ...@@ -381,6 +384,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
} }
/* Get the image local color map: */ /* Get the image local color map: */
GifFile->Image.ColorMap->SortFlag = SortFlag;
for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) { for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
if (READ(GifFile, Buf, 3) != 3) { if (READ(GifFile, Buf, 3) != 3) {
FreeMapObject(GifFile->Image.ColorMap); FreeMapObject(GifFile->Image.ColorMap);
...@@ -417,6 +421,7 @@ DGifGetImageDesc(GifFileType * GifFile) { ...@@ -417,6 +421,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
if (sp->ImageDesc.ColorMap == NULL) { if (sp->ImageDesc.ColorMap == NULL) {
return GIF_ERROR; return GIF_ERROR;
} }
sp->ImageDesc.ColorMap->SortFlag = GifFile->Image.ColorMap->SortFlag;
} }
sp->RasterBits = NULL; sp->RasterBits = NULL;
sp->ExtensionBlockCount = 0; sp->ExtensionBlockCount = 0;
......
...@@ -88,6 +88,7 @@ typedef struct GifColorType { ...@@ -88,6 +88,7 @@ typedef struct GifColorType {
typedef struct ColorMapObject { typedef struct ColorMapObject {
int ColorCount; int ColorCount;
int BitsPerPixel; int BitsPerPixel;
int SortFlag;
GifColorType *Colors; GifColorType *Colors;
} ColorMapObject; } ColorMapObject;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment