示例#1
0
        private void buttonEncode_Click(object sender, EventArgs e)
        {
            try
            {
                int key;
                if (!int.TryParse(textBoxGetEncodeKey.Text, out key))
                {
                    throw new Exception("Ошибка при вводе ключа!");
                }

                EncodeKey = Int32.Parse(textBoxGetEncodeKey.Text);

                SteganoTransformation transformation = new SteganoTransformation();
                SteganoContainer      container      = new SteganoContainer(ContainerForEncode);
                SteganoMessage        message        = new SteganoMessage(InputMessage);
                container.InitBlocks(8, 8);
                container.InitBlueComponent(8, 8);
                transformation.Encode(container, message, EncodeKey, 250);
                container.InsertBlueComponent(8, 8);
                container.SaveImage(8, 8, "encode_output.bmp");

                MessageBox.Show("Успешно!\nФайл находится в директории:\n" + Directory.GetCurrentDirectory(), "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception excptn)
            {
                MessageBox.Show("Анта бака!\nОшибка при кодировании!\n" + excptn.Message + excptn.StackTrace, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public double [] getPSNRValues(string original, string message, int maxP, int key)
        {
            double [] PSNRvalues = new double[maxP];

            Parallel.For(0, maxP, ctr => {
                SteganoTransformation transformation = new SteganoTransformation();
                SteganoContainer originalImage       = new SteganoContainer(original);
                SteganoContainer container           = new SteganoContainer(original);
                SteganoMessage originalMessage       = new SteganoMessage(message);
                container.InitBlocks(8, 8);
                container.InitBlueComponent(8, 8);
                transformation.Encode(container, originalMessage, key, ctr);
                container.InsertBlueComponent(8, 8);
                container.SaveBitmap(8, 8);
                double buf      = getPSNR(originalImage, container);
                PSNRvalues[ctr] = buf;
                container.Image.Dispose();
                originalImage.Image.Dispose();
            });

            return(PSNRvalues);
        }