473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

GetThumbnailImage

I am trying to use an Image control to get a thumbnail image with the
following code:

Private Sub GetThumbnail(ByVal img As Image, ByVal photo As Photo)
' Gets a thumbnail image from the file and sets the TnailFile property
' in the photo object.

Dim tImg As Image
Dim w As Integer = img.Width
Dim h As Integer = img.Height
Dim tWidth, tHeight As Integer
Dim tRatio As Double = h / w ' Get the image aspect ratio

If tRatio > 0.75 Then
' Thumbnail is a portrait
tHeight = 108
tWidth = CInt(108 / tRatio)
Else
' Thumbnail is a landscape
tHeight = CInt(144 * tRatio)
tWidth = 144
End If

Dim ms As New MemoryStream
Try
tImg = img.GetThumbnailImage(tWidth, tHeight, AddressOf
TnailAbort, IntPtr.Zero)
tImg.Save(ms, Imaging.ImageFormat.Jpeg)
Dim tNail(CInt(ms.Length - 1)) As Byte
tNail = ms.GetBuffer
photo.TnailFile = tNail
Finally
If Not ms Is Nothing Then ms.Close()
End Try
End Sub

When this sub executes I get an "Out of memory" error on an image that is
1.4MB with no embedded thumbnail. I do not get the error on an image that is
640KB with an embedded thumbnail, or an image that is 20KB with no embedded
thumbnail.

This happens on XP Pro with 512MB ram and Windows 2003 Server with 1GB ram.

Any help would be greatly appreciated. I have a user down right now because
of this problem.

--
Walt
Nov 21 '05 #1
1 3040
I should have mentioned, the "Out of memory" error occurs when ececuting the
img.GetThumbnailImage(...) method.

Help please!
--
Walt
"Walt" wrote:
I am trying to use an Image control to get a thumbnail image with the
following code:

Private Sub GetThumbnail(ByVal img As Image, ByVal photo As Photo)
' Gets a thumbnail image from the file and sets the TnailFile property
' in the photo object.

Dim tImg As Image
Dim w As Integer = img.Width
Dim h As Integer = img.Height
Dim tWidth, tHeight As Integer
Dim tRatio As Double = h / w ' Get the image aspect ratio

If tRatio > 0.75 Then
' Thumbnail is a portrait
tHeight = 108
tWidth = CInt(108 / tRatio)
Else
' Thumbnail is a landscape
tHeight = CInt(144 * tRatio)
tWidth = 144
End If

Dim ms As New MemoryStream
Try
tImg = img.GetThumbnailImage(tWidth, tHeight, AddressOf
TnailAbort, IntPtr.Zero)
tImg.Save(ms, Imaging.ImageFormat.Jpeg)
Dim tNail(CInt(ms.Length - 1)) As Byte
tNail = ms.GetBuffer
photo.TnailFile = tNail
Finally
If Not ms Is Nothing Then ms.Close()
End Try
End Sub

When this sub executes I get an "Out of memory" error on an image that is
1.4MB with no embedded thumbnail. I do not get the error on an image that is
640KB with an embedded thumbnail, or an image that is 20KB with no embedded
thumbnail.

This happens on XP Pro with 512MB ram and Windows 2003 Server with 1GB ram.

Any help would be greatly appreciated. I have a user down right now because
of this problem.

--
Walt

Nov 21 '05 #2

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

Similar topics

5
by: Andrew Banks | last post by:
Is it possible to use GetThumbnailImage with images being pulled from an SQL DB and if so how? All examples I've seen refer to working with an actual image stored on the server. My code for...
1
by: Comcast | last post by:
I understand that one of the limitations of the Image.GetThumbnailImage() function is that it's not really good for creating "large" thumbnails because if it exists in the image file, the function...
5
by: John | last post by:
I am trying to convert the regular sized images in a directory to thumbnails and then display the thumbnails in a datalist. My code below is displaying the first image and nothing else after it. ...
1
by: GrandpaB | last post by:
I am having difficulty implementing the GetThumbnailImage method. I have read the "Help" files on this method, but remain confused. My problem is understanding the last two parameters that the...
0
by: billsahiker | last post by:
Does anyone know how to call GetthumbnailImage in VB6? I am posting this here because .NET is where most of the use of GDIPlus is found and many of you are/were VB6 folks. I registered the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.