Exemplo n.º 1
0
        public void storeCustomFormat(Bitmap image, string name)
        {
            byte[] array = new byte[(imageModel.getHeight() / 2 * imageModel.getWidth() / 2) * 3];

            int counter = 0;

            for (int y = 0; y < imageModel.getHeight(); y += 2)
            {
                for (int x = 0; x < imageModel.getWidth(); x += 2)
                {
                    array[counter++] = image.GetPixel(x, y).R;
                    array[counter++] = image.GetPixel(x, y).G;
                    array[counter++] = image.GetPixel(x, y).B;
                }
            }

            uint originalDataSize = (uint)(imageModel.getHeight() / 2 * imageModel.getWidth() / 2) * 3;

            byte[] compressedData = new byte[originalDataSize * (101 / 100) + 384];

            int compressedDataSize = CompressionController.Compress(array, compressedData, originalDataSize);

            this.saveToCustomFormat(name, compressedDataSize, compressedData, image);

            MessageBox.Show("Compression done!");
        }