Пример #1
0
        private void getSlotsByImageType(string imagePath)
        {
            var trimPath = imagePath.ToLower().Trim();

            // Check image type
            if (trimPath.EndsWith(".jpg") || trimPath.EndsWith(".jpeg")) // JPEG
            {
                // Available slots not 0 - DCT values 0 won't be overwritten
                var dctCoeffs = JpegHelper.GetDctCoefficients(imagePath);
                // 2 bits for each dct coefficient (0 values are skpped)
                _slots = 2 * dctCoeffs.DctFullAc.Where(s => 0 != s).Count() - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".bmp")) // BITMAP
            {
                _slots = BmpHelper.GetAvailableSlots(imagePath) - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".png")) // PNG
            {
                _slots = PngHelper.GetAvailableSlots(imagePath) - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".gif")) // GIF
            {
                sldSecLevel.Value = 1;
                _slots            = GifHelper.GetAvailableSlots(imagePath) - HEADER_BITS_IDX_LEN;
            }
            else if (trimPath.EndsWith(".tif") || trimPath.EndsWith(".tiff")) // TIFF
            {
                sldSecLevel.Value = 1;
                _slots            = TifHelper.GetAvailableSlots(imagePath) - HEADER_BITS_IDX_LEN;
            }
            if (_slots < 10)
            {
                tbxSlots.Text = tbxSlotsUsed.Text = tbxSlotsLeft.Text = "0";
                MessageBox.Show("Image not suitable for embedding content.", "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }