Пример #1
0
        public void SaveImage(Bitmap image, string headerFilePath, string outputPath)
        {
            InitializeBitWriter(outputPath);

            ImageHeaderHandler.CopyHeaderFromFile(headerFilePath, bitWriter);

            var pixelMatrix = ImageMapper.GetPixelMatrixFromImage(image);

            WritePixelMatrix(pixelMatrix);
        }
Пример #2
0
        public void SaveToFile(EncodedImage encodedImage, string originalImagePath, SaveMode saveMode)
        {
            InitializeBitWriter(GetOutputPath(originalImagePath, encodedImage.PredictorSettings, saveMode));

            ImageHeaderHandler.CopyHeaderFromFile(originalImagePath, bitWriter);

            WritePredictorSettings(encodedImage.PredictorSettings, saveMode);

            WriteMatrix(encodedImage.QuantizedErrorPredictionMatrix, saveMode);
        }
Пример #3
0
        public EncodedImage ReadEncodedImage(string encodedImageFilePath)
        {
            bitsToRead = (new FileInfo(encodedImageFilePath).Length - 1078) * 8;

            InitializeBitReader(encodedImageFilePath);

            ImageHeaderHandler.SkipHeaderFromImage(bitReader);

            var predictorSettings = ReadPredictorSettings();
            var readSaveMode      = (SaveMode)Enum.GetValues(typeof(SaveMode)).GetValue(bitReader.ReadNBits(3));

            bitsToRead -= 4 + 4 + 3;

            return(new EncodedImage
            {
                PredictorSettings = predictorSettings,
                QuantizedErrorPredictionMatrix = ReadMatrix(readSaveMode)
            });
        }