/// <summary> /// Return image data /// </summary> public void HuffDecode(int[, ,] buffer) { int x, y, tmp; int sz = X * Y; int[,] Block = new int[8, 8]; int Cs, Ta, Td, blocks; // Read in Scan Header information Ls = dis.ReadInt(); Ns = dis.Read(); Cs = dis.Read(); Td = dis.Read(); Ta = Td & 0x0f; Td >>= 4; Ss = dis.Read(); Se = dis.Read(); Ah = dis.Read(); Al = Ah & 0x0f; Ah >>= 4; // Calculate the Number of blocks encoded // blocks = X * Y / 64; blocks = GetBlockCount() / 6; // decode image data and return image data in array for (j = 0; j < blocks; j++) { // Get DC coefficient if (Td == 0) { hftbl = 0; } else { hftbl = 2; } tmp = DECODE(); Diff = Receive(tmp); ZZ[0] = Pred + Extend(Diff, tmp); Pred = ZZ[0]; // Get AC coefficients if (Ta == 0) { hftbl = 1; } else { hftbl = 3; } Decode_AC_Coefficients(); // dezigzag and dequantize block for (i = 0; i < 64; i++) { Block[deZZ[i, 0], deZZ[i, 1]] = ZZ[i] * QNT[0][i]; } // store blocks in buffer for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { buffer[j, x, y] = Block[x, y]; } } } dis.Close(); }