Compress() публичный Метод

public Compress ( byte buf, int offset, int length ) : void
buf byte
offset int
length int
Результат void
Пример #1
0
        public static void CompressLZW(Stream stream, int predictor, byte[] b, int height, int samplesPerPixel, int stride)
        {
            LZWCompressor lzwCompressor = new LZWCompressor(stream, 8, true);
            bool          usePredictor  = predictor == TIFFConstants.PREDICTOR_HORIZONTAL_DIFFERENCING;

            if (!usePredictor)
            {
                lzwCompressor.Compress(b, 0, b.Length);
            }
            else
            {
                int    off    = 0;
                byte[] rowBuf = usePredictor ? new byte[stride] : null;
                for (int i = 0; i < height; i++)
                {
                    System.Array.Copy(b, off, rowBuf, 0, stride);
                    for (int j = stride - 1; j >= samplesPerPixel; j--)
                    {
                        rowBuf[j] -= rowBuf[j - samplesPerPixel];
                    }
                    lzwCompressor.Compress(rowBuf, 0, stride);
                    off += stride;
                }
            }

            lzwCompressor.Flush();
        }
Пример #2
0
        public static void CompressLZW(Stream stream, int predictor, byte[] b, int height, int samplesPerPixel, int stride)
        {
            LZWCompressor lzwCompressor = new LZWCompressor(stream, 8, true);
            bool usePredictor = predictor == TIFFConstants.PREDICTOR_HORIZONTAL_DIFFERENCING;

            if (!usePredictor) {
                lzwCompressor.Compress(b, 0, b.Length);
            } else {
                int off = 0;
                byte[] rowBuf = usePredictor ? new byte[stride] : null;
                for (int i = 0; i < height; i++) {
                    System.Array.Copy(b, off, rowBuf, 0, stride);
                    for (int j = stride - 1; j >= samplesPerPixel; j--) {
                        rowBuf[j] -= rowBuf[j - samplesPerPixel];
                    }
                    lzwCompressor.Compress(rowBuf, 0, stride);
                    off += stride;
                }
            }

            lzwCompressor.Flush();
        }