How can I show image thumbnail??

Discussion in 'ASP .Net' started by Trint Smith, Feb 2, 2004.

  1. Trint Smith

    Trint Smith Guest

    How can I show image thumbnail??
    thanks,
    Trint

    ..Net programmer


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trint Smith, Feb 2, 2004
    #1
    1. Advertising

  2. You may be able to use the GetThumbnailImage method.
    Here's more info:
    http://msdn.microsoft.com/library/d...emDrawingImageClassGetThumbnailImageTopic.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "Trint Smith" <> wrote in message
    news:...
    > How can I show image thumbnail??
    > thanks,
    > Trint
    >
    > Net programmer
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Steve C. Orr [MVP, MCSD], Feb 3, 2004
    #2
    1. Advertising

  3. Trint Smith

    Mark Guest

    Hi, use the GetThumbnailImage method of GDI

    Link below
    http://www.wimdows.net/articles/article.aspx?aid=9

    Cheers
    Mark


    --
    ===================================
    e-evolution.net
    ===================================
    "Trint Smith" <> wrote in message
    news:...
    > How can I show image thumbnail??
    > thanks,
    > Trint
    >
    > .Net programmer
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Mark, Feb 3, 2004
    #3
  4. "Trint Smith" <> wrote in message
    news:...
    > How can I show image thumbnail??
    > thanks,
    > Trint


    i made this class which uses the method that the other people suggested.

    usage:

    dim x as new ImageResizer

    x.sourcefilename = "c:\whatever.jpg"
    x.newwidth = 40 'you can specify either or both of newwidth and newheight
    x.saveas("c:\filename.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    easy, huh?
    Imports System.Drawing.Imaging

    'this class was written by Rimu Atkinson on 2nd December 2002

    'feel free to use this code for whatever purposes you like, but i'd
    appreciate it if you kept this comment block in

    Public Class ImageResizer

    Private m_FileName As String

    Public NewWidth As Integer = 0

    Public NewHeight As Integer = 0

    Property SourceFilename() As String 'the input file

    Get

    Return m_FileName

    End Get

    Set(ByVal Value As String)

    Dim f As System.IO.File

    If f.Exists(Value) Then

    m_FileName = Value

    Else

    m_FileName = vbNullString

    End If

    End Set

    End Property

    Public Function SaveAs(ByVal ThumbFileName As String, ByVal FileType As
    ImageFormat) As Boolean

    Dim img As Bitmap

    Dim ThumbNail As Bitmap

    Dim callbackdata As IntPtr

    Dim ratio As Single

    Dim myImageCodecInfo As ImageCodecInfo, myEncoder As Encoder,
    myEncoderParameters As EncoderParameters

    Dim myEncoderParameter As EncoderParameter

    If NewWidth = 0 And NewHeight = 0 Then Return False

    If m_FileName = vbNullString Then Return False

    myImageCodecInfo = GetEncoderInfo("image/jpeg")

    myEncoder = Encoder.Quality

    myEncoderParameters = New EncoderParameters(1)

    myEncoderParameter = New EncoderParameter(myEncoder, 65)

    myEncoderParameters.Param(0) = myEncoderParameter

    img = New Bitmap(m_FileName)

    'don't ask me why, but rotating the image 360 degrees improves the quality
    no end!

    img.RotateFlip(RotateFlipType.Rotate180FlipNone)

    img.RotateFlip(RotateFlipType.Rotate180FlipNone)



    If NewWidth <> 0 And NewHeight <> 0 Then

    ThumbNail = img.GetThumbnailImage(NewWidth, NewHeight, AddressOf
    AbortHandler, callbackdata)

    ElseIf NewWidth <> 0 And NewHeight = 0 Then

    ratio = NewWidth / img.Width

    ThumbNail = img.GetThumbnailImage(NewWidth, img.Height * ratio, AddressOf
    AbortHandler, callbackdata)

    ElseIf NewWidth = 0 And NewHeight <> 0 Then

    ratio = NewHeight / img.Height

    ThumbNail = img.GetThumbnailImage(img.Width * ratio, NewHeight, AddressOf
    AbortHandler, callbackdata)

    End If

    ThumbNail.Save(ThumbFileName, myImageCodecInfo, myEncoderParameters)

    img.Dispose()

    Return True

    End Function

    Private Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo

    Dim j As Integer

    Dim encoders() As ImageCodecInfo

    encoders = imagecodecinfo.GetImageEncoders

    For j = 0 To encoders.Length

    If encoders(j).MimeType = mimeType Then

    Return encoders(j)

    End If

    Next

    Return Nothing

    End Function

    Private Function AbortHandler() As Boolean

    'whatever.

    End Function

    End Class
    Rimu Atkinson, Feb 3, 2004
    #4
  5. Trint Smith

    TJS Guest

    not so easy..

    code doesn't compile , return is full of error messages ....


    "Rimu Atkinson" <> wrote in message
    news:0zETb.20378$...
    >
    > "Trint Smith" <> wrote in message
    > news:...
    > > How can I show image thumbnail??
    > > thanks,
    > > Trint

    >
    > i made this class which uses the method that the other people suggested.
    >
    > usage:
    >
    > dim x as new ImageResizer
    >
    > x.sourcefilename = "c:\whatever.jpg"
    > x.newwidth = 40 'you can specify either or both of newwidth and newheight
    > x.saveas("c:\filename.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    >
    > easy, huh?
    > Imports System.Drawing.Imaging
    >
    > 'this class was written by Rimu Atkinson on 2nd December 2002
    >
    > 'feel free to use this code for whatever purposes you like, but i'd
    > appreciate it if you kept this comment block in
    >
    > Public Class ImageResizer
    >
    > Private m_FileName As String
    >
    > Public NewWidth As Integer = 0
    >
    > Public NewHeight As Integer = 0
    >
    > Property SourceFilename() As String 'the input file
    >
    > Get
    >
    > Return m_FileName
    >
    > End Get
    >
    > Set(ByVal Value As String)
    >
    > Dim f As System.IO.File
    >
    > If f.Exists(Value) Then
    >
    > m_FileName = Value
    >
    > Else
    >
    > m_FileName = vbNullString
    >
    > End If
    >
    > End Set
    >
    > End Property
    >
    > Public Function SaveAs(ByVal ThumbFileName As String, ByVal FileType As
    > ImageFormat) As Boolean
    >
    > Dim img As Bitmap
    >
    > Dim ThumbNail As Bitmap
    >
    > Dim callbackdata As IntPtr
    >
    > Dim ratio As Single
    >
    > Dim myImageCodecInfo As ImageCodecInfo, myEncoder As Encoder,
    > myEncoderParameters As EncoderParameters
    >
    > Dim myEncoderParameter As EncoderParameter
    >
    > If NewWidth = 0 And NewHeight = 0 Then Return False
    >
    > If m_FileName = vbNullString Then Return False
    >
    > myImageCodecInfo = GetEncoderInfo("image/jpeg")
    >
    > myEncoder = Encoder.Quality
    >
    > myEncoderParameters = New EncoderParameters(1)
    >
    > myEncoderParameter = New EncoderParameter(myEncoder, 65)
    >
    > myEncoderParameters.Param(0) = myEncoderParameter
    >
    > img = New Bitmap(m_FileName)
    >
    > 'don't ask me why, but rotating the image 360 degrees improves the quality
    > no end!
    >
    > img.RotateFlip(RotateFlipType.Rotate180FlipNone)
    >
    > img.RotateFlip(RotateFlipType.Rotate180FlipNone)
    >
    >
    >
    > If NewWidth <> 0 And NewHeight <> 0 Then
    >
    > ThumbNail = img.GetThumbnailImage(NewWidth, NewHeight, AddressOf
    > AbortHandler, callbackdata)
    >
    > ElseIf NewWidth <> 0 And NewHeight = 0 Then
    >
    > ratio = NewWidth / img.Width
    >
    > ThumbNail = img.GetThumbnailImage(NewWidth, img.Height * ratio, AddressOf
    > AbortHandler, callbackdata)
    >
    > ElseIf NewWidth = 0 And NewHeight <> 0 Then
    >
    > ratio = NewHeight / img.Height
    >
    > ThumbNail = img.GetThumbnailImage(img.Width * ratio, NewHeight, AddressOf
    > AbortHandler, callbackdata)
    >
    > End If
    >
    > ThumbNail.Save(ThumbFileName, myImageCodecInfo, myEncoderParameters)
    >
    > img.Dispose()
    >
    > Return True
    >
    > End Function
    >
    > Private Function GetEncoderInfo(ByVal mimeType As String) As

    ImageCodecInfo
    >
    > Dim j As Integer
    >
    > Dim encoders() As ImageCodecInfo
    >
    > encoders = imagecodecinfo.GetImageEncoders
    >
    > For j = 0 To encoders.Length
    >
    > If encoders(j).MimeType = mimeType Then
    >
    > Return encoders(j)
    >
    > End If
    >
    > Next
    >
    > Return Nothing
    >
    > End Function
    >
    > Private Function AbortHandler() As Boolean
    >
    > 'whatever.
    >
    > End Function
    >
    > End Class
    >
    >
    TJS, Feb 3, 2004
    #5
  6. Trint Smith

    Trint Smith Guest

    I haven't tried this yet, but there is also a sample in the help of
    vs.net.
    Thanks,
    Trint

    ..Net programmer


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trint Smith, Feb 13, 2004
    #6
  7. Trint Smith

    Jon Paal Guest

    this thing fails to compile ...


    "Rimu Atkinson" <> wrote in message news:0zETb.20378$...
    >
    > "Trint Smith" <> wrote in message
    > news:...
    >> How can I show image thumbnail??
    >> thanks,
    >> Trint

    >
    > i made this class which uses the method that the other people suggested.
    >
    > usage:
    >
    > dim x as new ImageResizer
    >
    > x.sourcefilename = "c:\whatever.jpg"
    > x.newwidth = 40 'you can specify either or both of newwidth and newheight
    > x.saveas("c:\filename.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    >
    > easy, huh?
    > Imports System.Drawing.Imaging
    >
    > 'this class was written by Rimu Atkinson on 2nd December 2002
    >
    > 'feel free to use this code for whatever purposes you like, but i'd
    > appreciate it if you kept this comment block in
    >
    > Public Class ImageResizer
    >
    > Private m_FileName As String
    >
    > Public NewWidth As Integer = 0
    >
    > Public NewHeight As Integer = 0
    >
    > Property SourceFilename() As String 'the input file
    >
    > Get
    >
    > Return m_FileName
    >
    > End Get
    >
    > Set(ByVal Value As String)
    >
    > Dim f As System.IO.File
    >
    > If f.Exists(Value) Then
    >
    > m_FileName = Value
    >
    > Else
    >
    > m_FileName = vbNullString
    >
    > End If
    >
    > End Set
    >
    > End Property
    >
    > Public Function SaveAs(ByVal ThumbFileName As String, ByVal FileType As
    > ImageFormat) As Boolean
    >
    > Dim img As Bitmap
    >
    > Dim ThumbNail As Bitmap
    >
    > Dim callbackdata As IntPtr
    >
    > Dim ratio As Single
    >
    > Dim myImageCodecInfo As ImageCodecInfo, myEncoder As Encoder,
    > myEncoderParameters As EncoderParameters
    >
    > Dim myEncoderParameter As EncoderParameter
    >
    > If NewWidth = 0 And NewHeight = 0 Then Return False
    >
    > If m_FileName = vbNullString Then Return False
    >
    > myImageCodecInfo = GetEncoderInfo("image/jpeg")
    >
    > myEncoder = Encoder.Quality
    >
    > myEncoderParameters = New EncoderParameters(1)
    >
    > myEncoderParameter = New EncoderParameter(myEncoder, 65)
    >
    > myEncoderParameters.Param(0) = myEncoderParameter
    >
    > img = New Bitmap(m_FileName)
    >
    > 'don't ask me why, but rotating the image 360 degrees improves the quality
    > no end!
    >
    > img.RotateFlip(RotateFlipType.Rotate180FlipNone)
    >
    > img.RotateFlip(RotateFlipType.Rotate180FlipNone)
    >
    >
    >
    > If NewWidth <> 0 And NewHeight <> 0 Then
    >
    > ThumbNail = img.GetThumbnailImage(NewWidth, NewHeight, AddressOf
    > AbortHandler, callbackdata)
    >
    > ElseIf NewWidth <> 0 And NewHeight = 0 Then
    >
    > ratio = NewWidth / img.Width
    >
    > ThumbNail = img.GetThumbnailImage(NewWidth, img.Height * ratio, AddressOf
    > AbortHandler, callbackdata)
    >
    > ElseIf NewWidth = 0 And NewHeight <> 0 Then
    >
    > ratio = NewHeight / img.Height
    >
    > ThumbNail = img.GetThumbnailImage(img.Width * ratio, NewHeight, AddressOf
    > AbortHandler, callbackdata)
    >
    > End If
    >
    > ThumbNail.Save(ThumbFileName, myImageCodecInfo, myEncoderParameters)
    >
    > img.Dispose()
    >
    > Return True
    >
    > End Function
    >
    > Private Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
    >
    > Dim j As Integer
    >
    > Dim encoders() As ImageCodecInfo
    >
    > encoders = imagecodecinfo.GetImageEncoders
    >
    > For j = 0 To encoders.Length
    >
    > If encoders(j).MimeType = mimeType Then
    >
    > Return encoders(j)
    >
    > End If
    >
    > Next
    >
    > Return Nothing
    >
    > End Function
    >
    > Private Function AbortHandler() As Boolean
    >
    > 'whatever.
    >
    > End Function
    >
    > End Class
    >
    >
    Jon Paal, Oct 7, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris D

    Thumbnail Image Quality Issues

    Chris D, Nov 18, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    324
    Chris D
    Nov 18, 2003
  2. moondaddy
    Replies:
    4
    Views:
    756
    S. Justin Gengo
    Jun 29, 2004
  3. David Lozzi
    Replies:
    1
    Views:
    488
    john smith
    Feb 1, 2006
  4. Disco Octopus

    to show image or to show flash

    Disco Octopus, May 13, 2004, in forum: HTML
    Replies:
    7
    Views:
    2,405
    Toby A Inkster
    May 14, 2004
  5. dodgeyb
    Replies:
    1
    Views:
    607
    George Ter-Saakov
    Dec 14, 2007
Loading...

Share This Page