locked
displaying the thumbnail of the image RRS feed

  • Question

  • i have a link inserted into the database , the link is of an image & i want to show the thumbnail of the image  on the screen
    | http://geekswithblogs.net/akshaylamba/ | Student , XI Akshay Deep Lamba
    Friday, March 19, 2010 1:25 PM

Answers

  • To create thumbnail of an image use the below code. I assume you already have an image opened in the memory stream or saved in the local temp folder.

    Image Img = ImageFromFile(“D:\\Wallpapers\\a.jpg”);
    Image thumb = Img.GetThumbnailImage(64,64, Image.GetThumbnailImageAbort(ThumbnailCallBack),IntPtr.Zero);
    
    Public bool ThumbnailCallBack()
    {
                    Return true;
    }
    


    www.midnightprogramer.net
    • Marked as answer by Harry Zhu Friday, March 26, 2010 1:44 AM
    Friday, March 19, 2010 1:36 PM
  • Please see the below ipdated code. I have modified the code a bit:

     

      public bool ThumbnailCallback()
            {
                    return true;
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                Image Img = Image.FromFile("C:\\p.jpg");
                Image thumbnailImage = Img.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                pictureBox1.Image = thumbnailImage;
            }
          


    www.midnightprogramer.net
    • Proposed as answer by MACIR Saturday, March 20, 2010 3:14 PM
    • Marked as answer by Harry Zhu Friday, March 26, 2010 1:44 AM
    Friday, March 19, 2010 4:00 PM

All replies

  • To create thumbnail of an image use the below code. I assume you already have an image opened in the memory stream or saved in the local temp folder.

    Image Img = ImageFromFile(“D:\\Wallpapers\\a.jpg”);
    Image thumb = Img.GetThumbnailImage(64,64, Image.GetThumbnailImageAbort(ThumbnailCallBack),IntPtr.Zero);
    
    Public bool ThumbnailCallBack()
    {
                    Return true;
    }
    


    www.midnightprogramer.net
    • Marked as answer by Harry Zhu Friday, March 26, 2010 1:44 AM
    Friday, March 19, 2010 1:36 PM
  • How will i use the variable img and thumb to display the image with
    ThumbnailCallBack()

    | http://geekswithblogs.net/akshaylamba/ | Student , XI Akshay Deep Lamba
    Friday, March 19, 2010 1:53 PM
  • take a picture box in your form and pass the 'thumb' object of Image class to it like:

    PictureBox1.Image = thumb;


    www.midnightprogramer.net
    Friday, March 19, 2010 1:57 PM
  • IT GIVES ME COMPILE TIME ERROR OF

    Error    1    'System.Drawing.Image.GetThumbnailImageAbort' is a 'type', which is not valid in the given context    E:\DTprg_Script\C#\GUI(Graphical User Interface)\IMAGE_THUMBNAIL\IMAGE_THUMBNAIL\Form1.cs    20    63    IMAGE_THUMBNAIL


    | http://geekswithblogs.net/akshaylamba/ | Student , XI Akshay Deep Lamba
    Friday, March 19, 2010 3:26 PM
  • Please see the below ipdated code. I have modified the code a bit:

     

      public bool ThumbnailCallback()
            {
                    return true;
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                Image Img = Image.FromFile("C:\\p.jpg");
                Image thumbnailImage = Img.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                pictureBox1.Image = thumbnailImage;
            }
          


    www.midnightprogramer.net
    • Proposed as answer by MACIR Saturday, March 20, 2010 3:14 PM
    • Marked as answer by Harry Zhu Friday, March 26, 2010 1:44 AM
    Friday, March 19, 2010 4:00 PM