473,594 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I show image thumbnail??

How can I show image thumbnail??
thanks,
Trint

..Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
6 1736
Hi, use the GetThumbnailIma ge method of GDI

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

Cheers
Mark
--
=============== =============== =====
e-evolution.net
=============== =============== =====
"Trint Smith" <tr********@hot mail.com> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...
How can I show image thumbnail??
thanks,
Trint

.Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
You may be able to use the GetThumbnailIma ge method.
Here's more info:
http://msdn.microsoft.com/library/de...ImageTopic.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" <tr********@hot mail.com> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...
How can I show image thumbnail??
thanks,
Trint

Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

"Trint Smith" <tr********@hot mail.com> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...
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.sourcefilenam e = "c:\whatever.jp g"
x.newwidth = 40 'you can specify either or both of newwidth and newheight
x.saveas("c:\fi lename.jpg", System.Drawing. Imaging.ImageFo rmat.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 myImageCodecInf o As ImageCodecInfo, myEncoder As Encoder,
myEncoderParame ters As EncoderParamete rs

Dim myEncoderParame ter As EncoderParamete r

If NewWidth = 0 And NewHeight = 0 Then Return False

If m_FileName = vbNullString Then Return False

myImageCodecInf o = GetEncoderInfo( "image/jpeg")

myEncoder = Encoder.Quality

myEncoderParame ters = New EncoderParamete rs(1)

myEncoderParame ter = New EncoderParamete r(myEncoder, 65)

myEncoderParame ters.Param(0) = myEncoderParame ter

img = New Bitmap(m_FileNa me)

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

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

If NewWidth <> 0 And NewHeight <> 0 Then

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

ElseIf NewWidth <> 0 And NewHeight = 0 Then

ratio = NewWidth / img.Width

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

ElseIf NewWidth = 0 And NewHeight <> 0 Then

ratio = NewHeight / img.Height

ThumbNail = img.GetThumbnai lImage(img.Widt h * ratio, NewHeight, AddressOf
AbortHandler, callbackdata)

End If

ThumbNail.Save( ThumbFileName, myImageCodecInf o, myEncoderParame ters)

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. GetImageEncoder s

For j = 0 To encoders.Length

If encoders(j).Mim eType = mimeType Then

Return encoders(j)

End If

Next

Return Nothing

End Function

Private Function AbortHandler() As Boolean

'whatever.

End Function

End Class
Nov 18 '05 #4
TJS
not so easy..

code doesn't compile , return is full of error messages ....
"Rimu Atkinson" <ri***@paradise .net.removenosp amthing.nz> wrote in message
news:0z******** ************@ne ws02.tsnz.net.. .

"Trint Smith" <tr********@hot mail.com> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...
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.sourcefilenam e = "c:\whatever.jp g"
x.newwidth = 40 'you can specify either or both of newwidth and newheight
x.saveas("c:\fi lename.jpg", System.Drawing. Imaging.ImageFo rmat.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 myImageCodecInf o As ImageCodecInfo, myEncoder As Encoder,
myEncoderParame ters As EncoderParamete rs

Dim myEncoderParame ter As EncoderParamete r

If NewWidth = 0 And NewHeight = 0 Then Return False

If m_FileName = vbNullString Then Return False

myImageCodecInf o = GetEncoderInfo( "image/jpeg")

myEncoder = Encoder.Quality

myEncoderParame ters = New EncoderParamete rs(1)

myEncoderParame ter = New EncoderParamete r(myEncoder, 65)

myEncoderParame ters.Param(0) = myEncoderParame ter

img = New Bitmap(m_FileNa me)

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

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

If NewWidth <> 0 And NewHeight <> 0 Then

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

ElseIf NewWidth <> 0 And NewHeight = 0 Then

ratio = NewWidth / img.Width

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

ElseIf NewWidth = 0 And NewHeight <> 0 Then

ratio = NewHeight / img.Height

ThumbNail = img.GetThumbnai lImage(img.Widt h * ratio, NewHeight, AddressOf
AbortHandler, callbackdata)

End If

ThumbNail.Save( ThumbFileName, myImageCodecInf o, myEncoderParame ters)

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. GetImageEncoder s

For j = 0 To encoders.Length

If encoders(j).Mim eType = mimeType Then

Return encoders(j)

End If

Next

Return Nothing

End Function

Private Function AbortHandler() As Boolean

'whatever.

End Function

End Class

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

..Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #6
this thing fails to compile ...
"Rimu Atkinson" <ri***@paradise .net.removenosp amthing.nzwrote in message news:0z******** ************@ne ws02.tsnz.net.. .
>
"Trint Smith" <tr********@hot mail.comwrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...
>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.sourcefilenam e = "c:\whatever.jp g"
x.newwidth = 40 'you can specify either or both of newwidth and newheight
x.saveas("c:\fi lename.jpg", System.Drawing. Imaging.ImageFo rmat.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 myImageCodecInf o As ImageCodecInfo, myEncoder As Encoder,
myEncoderParame ters As EncoderParamete rs

Dim myEncoderParame ter As EncoderParamete r

If NewWidth = 0 And NewHeight = 0 Then Return False

If m_FileName = vbNullString Then Return False

myImageCodecInf o = GetEncoderInfo( "image/jpeg")

myEncoder = Encoder.Quality

myEncoderParame ters = New EncoderParamete rs(1)

myEncoderParame ter = New EncoderParamete r(myEncoder, 65)

myEncoderParame ters.Param(0) = myEncoderParame ter

img = New Bitmap(m_FileNa me)

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

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

img.RotateFlip( RotateFlipType. Rotate180FlipNo ne)

If NewWidth <0 And NewHeight <0 Then

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

ElseIf NewWidth <0 And NewHeight = 0 Then

ratio = NewWidth / img.Width

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

ElseIf NewWidth = 0 And NewHeight <0 Then

ratio = NewHeight / img.Height

ThumbNail = img.GetThumbnai lImage(img.Widt h * ratio, NewHeight, AddressOf
AbortHandler, callbackdata)

End If

ThumbNail.Save( ThumbFileName, myImageCodecInf o, myEncoderParame ters)

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. GetImageEncoder s

For j = 0 To encoders.Length

If encoders(j).Mim eType = mimeType Then

Return encoders(j)

End If

Next

Return Nothing

End Function

Private Function AbortHandler() As Boolean

'whatever.

End Function

End Class


Oct 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3643
by: Phil Powell | last post by:
PHP 4.3.2 with --enable-exif I have the following class: <?php class ThumbGenerator extends MethodGeneratorForActionPerformer { function ThumbGenerator() { // CONSTRUCTOR
5
3463
by: Al Davis | last post by:
Note: I tried cross-posting this message to several newsgoups, including comp.lang.perl.misc, c.l.p.moderated, comp.infosystems.www.authoring.cgi, comp.lang.javascript and comp.lang.php. Nothing appeared on my news server, so I'm trying again - this time posting a separate copy of the message to each group. I'm thinking this should be fairly easy to accomplish - a quick and dirty ... what? ... script? program?
10
4138
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full resolution (ie. large). I have a database that contains references to the pictures. Currently I have to resize the jpgs manually, and then point the ImageUrl property at that jpg using databinding. This works fine. I would like to avoid the resizing step...
4
1347
by: moondaddy | last post by:
I have an app where users will upload photos to their shopping cart. When they review their cart I need to include a light weight thumbnail of the image they uploaded. how can I take the image a user uploaded (PixOfMom.jpg at 600k) and convert it to a thumbnail and put into the image url of a .net image control using vb.net 1.1? Thanks! -- moondaddy@nospam.com
4
2555
by: John Swan | last post by:
Hello. I'm trying to create a simple program that amongst other things creates a thumbnail of an image (Bitmap) to a set size determined by the user in pixels? The problem is: All of the examples I have seen so far are in c#. Can anyone please provide reference to a c++ managed version. Thanks. John
4
2638
by: karsting | last post by:
I am using this css. I have a link from the thumbnail to another page, but need to go to the same link on the pop-up image. IN STYLES } .thumbnail{ position: relative; z-index: 0;
1
3130
by: dodgeyb | last post by:
Hi there, Trying to allow client to upload image, thumbnail it, and save it into sql table image field. Code compiles & runs but image cannot be retrieved. any clues what I'm doing wrong pls ! Dim origImage As System.Drawing.Image = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream)
7
9522
by: sandeepk84 | last post by:
Hi all... I have file upload option in my web application. I use Struts 2. I wanted to show a preview of the uploaded file to the user. The uploaded file can be of any type like Image(png,jpeg,gif,etc.), PDF,doc,txt,ppt,xls,html,etc. As of now the user has to download the file if he wants to see it which is not a good idea.
0
7877
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8253
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8240
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3867
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1482
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.