C#: generate image thumbnail

//create the thumbnail 
int image_width = 96; 
int image_height = 96; 
Image imgThumbnail = imgOriginal.GetThumbnailImage(image_width, image_height, null, IntPtr.Zero); 
 
//save to file 
imgThumbnail.Save(Path.GetDirectoryName(AFileName) + @"\a2.bmp", ImageFormat.Bmp);

or

        private bool ThumbnailCallback()
        {
            return false;
        }
 
        private void ProcessImage(Image imgOriginal)
        {
            //create the thumbnail
            int image_width = 96;
            int image_height = 96;
            Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
            Image imgThumbnail = imgOriginal.GetThumbnailImage(image_width, image_height, myCallback, IntPtr.Zero);
 
            //save to files
            imgThumbnail.Save(Path.GetDirectoryName(AFileName) + @"\a2.png");
        }

Tags:

Leave a Reply

You must be logged in to post a comment.