在WPF中生成缩略图图像

Jos*_*osh 0 c# wpf image thumbnails

在以下方案中如何在WPF中生成缩略图图像?

       using (MemoryStream mem = new MemoryStream(imgbytes))
            {
                BitmapImage jpgimage = new BitmapImage();
                jpgimage.BeginInit();

                jpgimage.CacheOption = BitmapCacheOption.OnLoad;

                jpgimage.StreamSource = mem;

                jpgimage.EndInit();

                Image wpfimage = new Image();
                wpfimage.Source = jpgimage.Clone();

                lbx.Items.Add(wpfimage);
                lbx.UpdateLayout();
                Thread.Sleep(1000);
            }
Run Code Online (Sandbox Code Playgroud)

Abi*_*hew 5

这个对我很有用

        <Image Width="120" Height="120" HorizontalAlignment="Center">
            <Image.Source>              
                <BitmapImage DecodePixelWidth="100" DecodePixelHeight="100" UriSource="Garden.jpg" />
            </Image.Source>
        </Image>
Run Code Online (Sandbox Code Playgroud)