Пример #1
0
        public void HideTest3()
        {
            string      file            = PathHelper.GetFilePath(@"\Data\testDocx.docx");
            string      coverImageUri   = PathHelper.GetFilePath(@"\Data\boy.bmp");
            BitmapImage bitmapImgTohide = FileTransform.ImageUri2BitmapImage(coverImageUri);
            Bitmap      imgTohide       = FileTransform.BitmapImage2Bitmap(bitmapImgTohide);


            var expected = FileTransform.File2ByteArray(file);

            HideLSB.Hide(ref imgTohide, expected);
            byte[] actual = HideLSB.DeHide(imgTohide);

            CollectionAssert.AreEqual(expected, actual);
        }
Пример #2
0
        public void ExecuteOpenFile(object args)
        {
            try
            {
                var fileTypesPattern = "bmp file (*.bmp)|*.bmp|All files (*.*)|*.*";
                var defaultExt       = "bmp";
                var imageUri         = GetFilePathFromFileDialog.GetFilePathFromOpenFileDialog(fileTypesPattern, defaultExt);

                if (string.IsNullOrEmpty(imageUri))
                {
                    return;
                }

                var bitmapImg   = FileTransform.ImageUri2BitmapImage(imageUri);
                var bitmapCache = FileTransform.BitmapImage2Bitmap(bitmapImg);

                var openCmdPara = (string)args;
                if ("Cover".Equals(openCmdPara))
                {
                    this.CoverImage              = bitmapImg;
                    this._coverImageBitmapCache  = bitmapCache;
                    this.HiddenImage             = null;
                    this._hiddenImageBitmapCache = null;
                }
                else if ("Hidden".Equals(openCmdPara))
                {
                    this.HiddenImage             = bitmapImg;
                    this._hiddenImageBitmapCache = bitmapCache;
                    this.CoverImage             = null;
                    this._coverImageBitmapCache = null;
                }

                this.ImageFilePath = imageUri;
            }
            catch (FileFormatException)
            {
                this.ShowMessageBoxResource("MustBeBmpFile", "Hint");
            }
            catch (Exception)
            {
                this.ShowMessageBoxResource("MustBeBmpFile", "Hint");
            }
        }