/// <summary>
        /// Forward application of the algorithm
        /// </summary>
        /// <param name="parOriginalImage">Original image stream</param>
        /// <param name="parArguments">List of an arguments (long qualityLevel, ImageFormat interimFormat)</param>
        /// <returns>Compressed image stream</returns>
        public override Stream CompressImage(Stream parOriginalImage, List <object> parArguments)
        {
            Bitmap original = new Bitmap(parOriginalImage);

            original.RotateFlip(RotateFlipType.Rotate90FlipNone);
            Stream rotatedImage = new MemoryStream();

            original.Save(rotatedImage, ImageFormat.Bmp);
            HInterlacingWithGZIP hInterlacing = HInterlacingWithGZIP.GetInstance();

            return(hInterlacing.CompressImage(rotatedImage, parArguments));
        }
        /// <summary>
        /// Inverse application of the algorithm
        /// </summary>
        /// <param name="parCompressedImage">Compressed image stream</param>
        /// <param name="parArguments">List of an arguments (ImageFormat finalFormat)</param>
        /// <returns>Decompressed image stream</returns>
        public override Stream DecompressImage(Stream parCompressedImage, List <object> parArguments)
        {
            HInterlacingWithGZIP hInterlacing = HInterlacingWithGZIP.GetInstance();
            Stream rotatedImage  = hInterlacing.DecompressImage(parCompressedImage, parArguments);
            Bitmap reconstructed = new Bitmap(rotatedImage);

            reconstructed.RotateFlip(RotateFlipType.Rotate270FlipNone);
            Stream      reconstructedImage = new MemoryStream();
            ImageFormat format             = (ImageFormat)parArguments[0];

            reconstructed.Save(reconstructedImage, format);

            return(reconstructedImage);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Main form constructor
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            _panels = new Hashtable();
            _panels.Add(panelQuality, new List <string>()
            {
                "JPEG"
            });
            _panels.Add(panelCompression, new List <string>()
            {
                "TIFF"
            });
            _panels.Add(panelWaveletLevels, new List <string>()
            {
                "Wavelet+GZIP"
            });
            _panels.Add(panelCompressionLevel, new List <string>()
            {
                "GZIP",
                "HInterlacing+GZIP",
                "VInterlacing+GZIP",
                "XInterlacing+GZIP",
                "Wavelet+GZIP"
            });
            _panels.Add(panelInterimFormat, new List <string>()
            {
                "HInterlacing+GZIP",
                "VInterlacing+GZIP",
                "XInterlacing+GZIP",
                "Wavelet+GZIP"
            });
            _panels.Add(panelFinalFormat, new List <string>()
            {
                "HInterlacing+GZIP",
                "VInterlacing+GZIP",
                "XInterlacing+GZIP",
                "Wavelet+GZIP"
            });

            cmbAlgorithm.Items.Clear();
            cmbAlgorithm.Items.Add(JPEG.GetInstance());
            cmbAlgorithm.Items.Add(PNG.GetInstance());
            cmbAlgorithm.Items.Add(TIFF.GetInstance());
            cmbAlgorithm.Items.Add(GZIP.GetInstance());
            cmbAlgorithm.Items.Add(HInterlacingWithGZIP.GetInstance());
            cmbAlgorithm.Items.Add(VInterlacingWithGZIP.GetInstance());
            cmbAlgorithm.Items.Add(XInterlacingWithGZIP.GetInstance());
            cmbAlgorithm.Items.Add(WaveletWithGZIP.GetInstance());
            cmbAlgorithm.SelectedIndex = 0;

            cmbCompression.Items.Clear();
            cmbCompression.Items.Add("Default");
            cmbCompression.Items.Add("None");
            cmbCompression.Items.Add("CCITT3");
            cmbCompression.Items.Add("CCITT4");
            cmbCompression.Items.Add("LZW");
            cmbCompression.Items.Add("RLE");
            cmbCompression.Items.Add("ZIP");
            cmbCompression.Items.Add(".NET default");
            cmbCompression.SelectedIndex = 7;

            cmbCompressionLevel.Items.Clear();
            cmbCompressionLevel.Items.Add("Optimal");
            cmbCompressionLevel.Items.Add("Fast");
            cmbCompressionLevel.Items.Add("None");
            cmbCompressionLevel.SelectedIndex = 0;

            cmbInterimFormat.Items.Clear();
            cmbInterimFormat.Items.Add(ImageFormat.Bmp);
            cmbInterimFormat.Items.Add(ImageFormat.Png);
            cmbInterimFormat.Items.Add(ImageFormat.Tiff);
            cmbInterimFormat.SelectedIndex = 0;

            cmbFinalFormat.Items.Clear();
            cmbFinalFormat.Items.Add(ImageFormat.Bmp);
            cmbFinalFormat.Items.Add(ImageFormat.Png);
            cmbFinalFormat.Items.Add(ImageFormat.Tiff);
            cmbFinalFormat.SelectedIndex = 0;

            _resultExtension = null;
        }