Пример #1
0
        private void btnPicker_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "(*.bmp)|*.bmp;";
            if (ofd.ShowDialog() == true)
            {
                using (var imageFileStream = ofd.OpenFile())
                {
                    var buffer = new byte[imageFileStream.Length];
                    imageFileStream.Read(buffer, 0, buffer.Length);
                    var source = BitmapHelper.ByteArrayToBitmapImage(buffer);
                    imgSrc.Source = srcBitmap = source;
                }
            }
        }
Пример #2
0
        public void PickImage()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "(*.bmp)|*.bmp;";
            if (ofd.ShowDialog() == true)
            {
                using (var imageFileStream = ofd.OpenFile())
                {
                    var buffer = new byte[imageFileStream.Length];
                    imageFileStream.Read(buffer, 0, buffer.Length);
                    var source = BitmapHelper.ByteArrayToBitmapImage(buffer);
                    SrcBitmapSource = source;

                    LogMessage($"大小({buffer.Length}Byte)", "加载图片");
                }
            }
        }