コード例 #1
0
        /// <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)
        {
            GZIP   gzip = GZIP.GetInstance();
            Stream decompressedWavelet = gzip.DecompressImage(parCompressedImage, new List <object>());

            Bitmap wavelet = new Bitmap(decompressedWavelet);
            int    levels  = (int)parArguments[0];

            HaarWavelet.ApplyTransform(ref wavelet, false, levels);

            Stream      result = new MemoryStream();
            ImageFormat format = (ImageFormat)parArguments[1];

            wavelet.Save(result, format);

            return(result);
        }
コード例 #2
0
        /// <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);
            int    levels   = (int)parArguments[0];

            HaarWavelet.ApplyTransform(ref original, true, levels);

            Stream      waveletStream = new MemoryStream();
            ImageFormat format        = (ImageFormat)parArguments[2];

            original.Save(waveletStream, format);

            GZIP   gzip             = GZIP.GetInstance();
            int    compressionLevel = (int)parArguments[1];
            Stream compressedImage  = gzip.CompressImage(waveletStream, new List <object>()
            {
                compressionLevel
            });

            return(compressedImage);
        }