async Task ParseAsync(GIFDecoderStreamReader stream, bool skipTypeIdentifier) { if (!skipTypeIdentifier) { TypeIdentifier = stream.ReadString(3); } else { TypeIdentifier = "GIF"; } if (IsGIFHeader) { Version = stream.ReadString(3); Width = stream.ReadShort(); Height = stream.ReadShort(); int flags = stream.Read(); BackgroundColorIndex = stream.Read(); PixelAspectRatio = stream.Read(); if (UseGlobalColorTable(flags)) { GlobalColorTable = await GIFColorTable.CreateColorTableAsync(stream, GlobalColorTableSize(flags)).ConfigureAwait(false); BackgroundColor = GlobalColorTable.Data[BackgroundColorIndex]; } } else { throw new GIFDecoderFormatException("Unknown GIF format type identifier: " + TypeIdentifier); } }
public static async Task <GIFColorTable> CreateColorTableAsync(GIFDecoderStreamReader stream, short size) { var colorTable = new GIFColorTable(size); await colorTable.ParseAsync(stream).ConfigureAwait(false); return(colorTable); }
async Task ParseGIFBitmapHeaderAsync(GIFDecoderStreamReader stream) { Bounds = new GIFBitmap.Rect(stream.ReadShort(), stream.ReadShort(), stream.ReadShort(), stream.ReadShort()); ColorTable = _header.GlobalColorTable; int flags = stream.Read(); if (UseLocalColorTable(flags)) { ColorTable = await GIFColorTable.CreateColorTableAsync(stream, LocalColorTableSize(flags)).ConfigureAwait(false); } BackgroundColor = _header.BackgroundColor; IsInterlaced = UseInterlace(flags); }