private static void DecodeMajMinH(byte[] buffer, int width, int height, int stripX, byte[] source, int sourcePos, int indexSize, bool transparent) { int runlength = 0; LEBitStream sourceStream = new LEBitStream(source, sourcePos); byte color = sourceStream.GetByte(); int x = stripX; int y = 0; while (y < height) { while (x < stripX + 8) { buffer[y * width + x] = color; x++; if (runlength > 0) { runlength--; continue; } if (sourceStream.GetBit() == 0) // 0 { } else if (sourceStream.GetBit() == 0) // 10 { color = (byte)(sourceStream.GetBits(indexSize)); } else // 11 { int code = sourceStream.GetBits(3) - 4; if (code != 0) { color = (byte)(color + code); } else { runlength = sourceStream.GetBits(8) - 1; } } } x = stripX; y++; } }
private static void DecodeZigzagH(byte[] buffer, int width, int height, int stripX, byte[] source, int sourcePos, int indexSize, bool transparent) { int sub = 1; LEBitStream sourceStream = new LEBitStream(source, sourcePos); byte color = sourceStream.GetByte(); int x = stripX; int y = 0; while (y < height) { while (x < stripX + 8) { buffer[y * width + x] = color; if (sourceStream.GetBit() == 0) // 0 { // Do nothing (draw pixel, same color) } else if (sourceStream.GetBit() == 0) // 10 { color = (byte)(sourceStream.GetBits(indexSize)); sub = 1; } else if (sourceStream.GetBit() == 0) // 110 { color = (byte)(color - sub); } else // 111 { sub = -sub; color = (byte)(color - sub); } x++; } x = stripX; y++; } }