public Bitmap DecodeImage(Stream inps) { if (inps == null) { return(null); } // !!!{{ TODO: add the decoding code here IEntropyCodec c = new DeflateCodec(); c.BinaryStream = inps; c.Open(false); uint magic = (uint)c.GetBits(32); if (magic != MAGIC) { return(null); } int width, height; width = (int)c.GetBits(16); height = (int)c.GetBits(16); if (width < 1 || height < 1) { return(null); } Bitmap result = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int gr = c.Get(); if (gr < 0) { goto fin; } result.SetPixel(x, y, Color.FromArgb(gr, gr, gr)); } } fin: c.Close(); return(result); // !!!}} }