Results 1 to 3 of 3

Thread: Create thumbnails dynamically in Vb.net

  1. #1
    GonzalezBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default Create thumbnails dynamically in Vb.net

    I am new in this forum. I have one problem with my Vb.net example. I want to create thumbnails dynamically in Vb.net .how it is possible. Please give me step by step code which easy to understand me. Your help highly appericated.

  2. #2
    LewisClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default

    I suggest you to refer following example, which will give you something idea about the use code to Create thumbnails dynamically:

    Code:
        Function CreateThumbnail(ByVal inSourceFile As String, ByVal inDestinationFile As String, ByVal ThumbWidth As Integer, ByVal ThumbHeight As Integer) As Boolean
         
            Dim imageFile As System.Drawing.Image
            Dim outputFstream As New FileStream(inSourceFile, FileMode.Open, FileAccess.Read) 
            Dim ImageAbortCallBack As System.Drawing.Image.GetThumbnailImageAbort 
            imageFile = System.Drawing.Image.FromStream(outputFstream)
            ImageAbortCallBack = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf             ImageAbortDummyCallback)
            imageFile = imageFile.GetThumbnailImage(ThumbWidth, ThumbHeight, ImageAbortCallBack, IntPtr.Zero) 
            'IntPtr = A platform-specific type that is used to represent a pointer or a handle.
            imageFile.Save(inDestinationFile, System.Drawing.Imaging.ImageFormat.Jpeg)
            outputFstream.Close()
            outputFstream = Nothing
            imageFile = Nothing
    
        End Function

  3. #3
    WalkerCook is offline Senior Member
    Join Date
    Dec 2009
    Posts
    253
    Rep Power
    3

    Default

    Try this,

    Code:
     Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As EventArgs)
                      If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                            txtFileNm.Text = openFileDialog1.FileName
                      End If
                End Sub
     Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As EventArgs)
                      If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                            txtFileNm.Text = openFileDialog1.FileName
                      End If
                End Sub
    Dim imgThumb As Image = Nothing
                Private Sub btnGenerateThumbnail_Click(ByVal sender As Object, ByVal e As EventArgs)
                      Try
                            Dim image As Image = Nothing
                            ' Check if textbox has a value
                            If txtFileNm.Text <> String.Empty Then
                                  image = Image.FromFile(txtFileNm.Text)
                            End If
                            ' Check if image exists
                            If Not image Is Nothing Then
                                  imgThumb = image.GetThumbnailImage(100, 100, Nothing, New IntPtr())
                                  Me.Refresh()
                            End If
                      Catch
                            MessageBox.Show("An error occured")
                      End Try
                End Sub
    
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
                      If Not imgThumb Is Nothing Then
                      e.Graphics.DrawImage(imgThumb,30, 20, imgThumb.Width, imgThumb.Height)
                      End If
                End Sub

Similar Threads

  1. How to create thumbnails dynamically in asp.net
    By JacksonPerez in forum other peripherals
    Replies: 1
    Last Post: 06-12-2010, 11:12 AM
  2. Events Dynamically
    By BellWard in forum Programming
    Replies: 2
    Last Post: 02-04-2010, 06:00 PM
  3. Replies: 1
    Last Post: 01-11-2010, 09:54 AM
  4. [DLL] dynamically Laison a dll class
    By Caden Butcher in forum Programming
    Replies: 7
    Last Post: 10-22-2009, 12:17 PM
  5. Replies: 0
    Last Post: 04-20-2009, 07:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48