Controls the quality of the thumbnail images created by the control.
public RasterSizeFlags ThumbnailSizeFlags { get; set; }
A Leadtools.RasterSizeFlags enumeration that controls quality of the thumbnail images created by the control.
The RasterThumbnailBrowser control creates thumbnail for the images found as a result of calling the LoadThumbnails(String,String,RasterThumbnailBrowserLoadFlags) method. Some of these images might be larger than the ItemImageSize value, so the control will create a thumbnail of these images. You can control the speed and quality of the thumbnail creation operation by changing the ThumbnailSizeFlags property. For example, RasterSizeFlags.Normal will result in the fastest thumbnail creation operation but with lower quality. RasterSizeFlags.Bicubic will result in very high quality thumbnails, but the process of creating these thumbnails is much slower. Several other options are available, for more information, refer to the Leadtools.RasterSizeFlags enumeration.
Important note: RasterSizeFlags.FavorBlack is not supported in loading image thumbnails. If this flag is set, the RasterThumbnailBrowser control will use RasterSizeFlags.Bicubic instead.
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;class MyForm : Form{public RasterThumbnailBrowser theBrowser;public bool cancelOperation; // Informs us if the user canceled the operationpublic Button buttonCancel; // Cancel browse loadingpublic Button buttonBrowse; // Diplays the browse controlpublic ProgressBar progressBar; // shows progress of loading browse imagesvoid buttonBrowse_Click(object sender, EventArgs e){// If we are already loading thumbails, cancel// this operationif (theBrowser.IsLoadingThumbnails)theBrowser.CancelLoadingThumbnails();// Clean all the itemstheBrowser.Items.Clear();// Update the application statebuttonCancel.Enabled = true;progressBar.Value = 0;// And load the new thumbnailscancelOperation = false;string folderPath = LEAD_VARS.ImagesDir;theBrowser.LoadStamp = true;theBrowser.LoadThumbnails(folderPath, "*.*", RasterThumbnailBrowserLoadFlags.Block);theBrowser.Refresh();theBrowser.EnableBrowserWatcher = true;}private void thumbnailBrowser_LoadThumbnail(object sender, RasterThumbnailBrowserLoadThumbnailEventArgs e){// If this is the first iteration, update the progress bar minimum and maximum valuesif (e.Index == 0){progressBar.Minimum = 0;progressBar.Maximum = e.Total - 1;}// Update where we are in the loading operationprogressBar.Value = e.Index;// Check if we need to cancel (due to the user clicking the Cancel button)if (cancelOperation)e.Cancel = true;}private void thumbnailBrowser_AddFile(object sender, RasterThumbnailBrowserAddFileEventArgs e){Console.WriteLine("AddFile: {0} Add: {1}", e.FileName, e.Add);}private void thumbnailBrowser_FinishedLoadingThumbnails(object sender, EventArgs e){buttonCancel.Enabled = false;}private void buttonCancel_Click(object sender, EventArgs e){// The user has clicked the cancel buttonthis.cancelOperation = true;}// Create custom images to use as the "error" and "loading" thumbnails.void CreateErrorThumbnail(){// Get the image sizeSize imageSize = theBrowser.ItemImageSize;// No "loading" thumbnailtheBrowser.LoadingThumbnail = null;// For the "error" thumbnail, create a red X imageRasterColor[] palette = new RasterColor[0];RasterImage image = new RasterImage(RasterMemoryFlags.Conventional,imageSize.Width,imageSize.Height,24,RasterByteOrder.Bgr,RasterViewPerspective.TopLeft,palette,IntPtr.Zero,0);IntPtr hdc = RasterImagePainter.CreateLeadDC(image);Graphics g = Graphics.FromHdc(hdc);g.FillRectangle(Brushes.Magenta, 0, 0, imageSize.Width, imageSize.Height);g.DrawLine(Pens.Red, 0, 0, imageSize.Width, imageSize.Height);g.DrawLine(Pens.Red, imageSize.Width, 0, 0, imageSize.Height);g.Dispose();RasterImagePainter.DeleteLeadDC(hdc);// Make this image transparentimage.Transparent = true;image.TransparentColor = RasterColor.FromKnownColor(RasterKnownColor.Magenta);theBrowser.ErrorThumbnail = image;}public void Cleanup(){buttonBrowse.Click -= new EventHandler(buttonBrowse_Click);buttonCancel.Click -= new EventHandler(buttonCancel_Click);theBrowser.LoadThumbnail -= new EventHandler<RasterThumbnailBrowserLoadThumbnailEventArgs>(thumbnailBrowser_LoadThumbnail);theBrowser.FinishedLoadingThumbnails -= new EventHandler(thumbnailBrowser_FinishedLoadingThumbnails);}public MyForm(){Size = new Size(300, 200);// create the browsertheBrowser = new RasterThumbnailBrowser();theBrowser.Codecs = new RasterCodecs();theBrowser.Dock = DockStyle.Fill;theBrowser.ItemSpacingSize = new Size(10, 10);theBrowser.ThumbnailSizeFlags = RasterSizeFlags.Bicubic;theBrowser.LoadThumbnail += new EventHandler<RasterThumbnailBrowserLoadThumbnailEventArgs>(thumbnailBrowser_LoadThumbnail);theBrowser.FinishedLoadingThumbnails += new EventHandler(thumbnailBrowser_FinishedLoadingThumbnails);theBrowser.AddFile += new EventHandler<RasterThumbnailBrowserAddFileEventArgs>(thumbnailBrowser_AddFile);// Create a thumbnail image to be displayed on errorCreateErrorThumbnail();// add a panelPanel panel = new Panel();panel.Dock = DockStyle.Left;panel.Width = 100;Controls.Add(panel);panel.BringToFront();// add a "browse" buttonbuttonBrowse = new Button();buttonBrowse.Text = "Browse";buttonBrowse.Dock = DockStyle.Top;panel.Controls.Add(buttonBrowse);buttonBrowse.Click += new EventHandler(buttonBrowse_Click);// add a "cancel" buttonbuttonCancel = new Button();buttonCancel.Text = "Cancel";buttonBrowse.Dock = DockStyle.Bottom;panel.Controls.Add(buttonCancel);buttonCancel.Click += new EventHandler(buttonCancel_Click);// add a progress barprogressBar = new ProgressBar();progressBar.Dock = DockStyle.Bottom;Controls.Add(progressBar);Controls.Add(theBrowser);theBrowser.BringToFront();}private void InitializeComponent(){this.SuspendLayout();//// MyForm//this.ClientSize = new System.Drawing.Size(315, 273);this.Name = "MyForm";this.ResumeLayout(false);}}public void RasterThumbnailBrowser_RasterThumbnailBrowser(){MyForm form = new MyForm();form.ShowDialog();form.Cleanup();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}