VintaSoft Imaging .NET SDK and Plug-ins Discussions

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

How to get the generated Thumbnail from WpfThumbnailViewer as BitmapImage



How to get the generated Thumbnail from WpfThumbnailViewer as BitmapImage

Post by sebascomeau »

How to get the generated Thumbnail from WpfThumbnailViewer as BitmapImage. My code always return the full size of the original image. Something`s wrong with my code or yours.

Here`s my code
// generate thumbnail image source
BitmapImage imageSource = new BitmapImage();

using(MemoryStream ms = new MemoryStream())
{
    thumbnailImageItem.Source.Thumbnail.GetThumbnailImage(64, 64).Save(ms, new Vintasoft.Imaging.Codecs.Encoders.JpegEncoder());
                        
    ms.Seek(0, SeekOrigin.Begin);
    imageSource.BeginInit();
    imageSource.StreamSource = ms;
    imageSource.EndInit();
}
SГ©bastien Comeau


Re: How to get the generated Thumbnail from WpfThumbnailViewer as BitmapImage

Post by sebascomeau »

I change my code and the with and height of my bitmap is now good.
BitmapSource imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(thumbnailImageItem.Source.Thumbnail.GetThumbnailImage(64, 64).GetAsBitmap().GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());


Re: How to get the generated Thumbnail from WpfThumbnailViewer as BitmapImage

Post by Alex »

Hello Sebastien,

Your code is very complex.

You can get generated thumbnail from WpfThumbnailViewer as BitmapImage using the following code:
BitmapSource thumbnailBitmap = ThumbnailImageItem.ThumbnailSource;
Also at any time you can render thumbnail of any size using the following code:
BitmapSource thumbnailBitmap;
VintasoftImage image = thumbnailImageItem.Source;
using (VintasoftImage thumbnailImage = image.Thumbnail.GetThumbnailImage(128,128))
  thumbnailBitmap = VintasoftImageConverter.ToBitmapSource(thumbnailImage);
Best regards, Alexander


Page 1 from 1: 1