public void Read(Stream s) { Desc.Read(s); if (Desc.GlobalColorTableFlag) { GlobalColorTable = new GifColorTable(); GlobalColorTable.ColorsAmount = (int)Math.Pow(2, Desc.SizeOfGlobalColorTable + 1); GlobalColorTable.Read(s); } }
public Bitmap GetDecodedBmp(int _index) { var fr = GetRenderBlock(_index); var gce = GetGceBlock(fr); LastRenderBlock = fr; LastGceBlock = gce; Bitmap decbmp = new Bitmap(fr.Width, fr.Height); LockBitmap l = new LockBitmap(decbmp); l.LockBits(); var dec = GifParser.GetDecodedData(fr); GifColorTable clrt = LogicalScreen.GlobalColorTable; if (fr.LocalColorTableFlag) { clrt = fr.ColorTable; } for (int i = 0; i < fr.Width; i++) { for (int j = 0; j < fr.Height; j++) { int index = j * fr.Width + i; var clr = clrt.Colors[dec[index]]; if (gce.TransparencyFlag && gce.TransparentColorIndex == dec[index]) { l.SetPixel(i, j, Color.Transparent); } else { l.SetPixel(i, j, clr); } } } l.UnlockBits(); return(decbmp); }