473,396 Members | 1,768 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,396 software developers and data experts.

showing a list of dynamically resized images...

hi there,

i've a function that reads image filenames from database, and displays into
a repeater control, but what i'm trying to acheive is as i loop through each
filename, i want to resize it to say 100 pixels wide(which i already have
function for) and it returns a System.Drawing.Bitmap object - now this, i
want to get the image from here and put it into an <asp:imagecontrol.

my code so far...

---------------------------------------------------
Function ResizeImage(ByVal s As IO.Stream, ByVal maxWidth As Integer) As
System.Drawing.Bitmap
Dim oImage As System.Drawing.Image =
System.Drawing.Image.FromStream(s)

'check image width and orientation...
Dim newWidth, newHeight As Integer
If oImage.Width maxWidth Then
Dim tmpW As Decimal = oImage.Width / maxWidth
newWidth = maxWidth
newHeight = oImage.Height / tmpW
Else
'image size is okay.. use the original uploaded size.
newWidth = oImage.Width
newHeight = oImage.Height
End If
Dim bmpOut As New Bitmap(newWidth, newHeight)
Dim g As Graphics = Graphics.FromImage(bmpOut)
g.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic
g.FillRectangle(Brushes.White, 0, 0, newWidth, newHeight)
g.DrawImage(oImage, 0, 0, newWidth, newHeight)
oImage.Dispose()

ResizeImage = bmpOut
g.Dispose()
g = Nothing
bmpOut.Dispose()
bmpOut = Nothing
oImage.Dispose()
oImage = Nothing
End Function

Private Sub photoslist_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
photoslist.ItemDataBound
If Not (e.Item.DataItem Is Nothing) Then
Dim p As PhotoAlbum.Photo = e.Item.DataItem
Dim img As WebControls.Image = e.Item.FindControl("img")

'resize the image on the fly....
'i know this is wrong, here is where i need help...
Dim s As New IO.StreamReader(Server.MapPath(".") & "\gallery\" &
Request.QueryString("id") & "\" & p.Filename)
img.imageurl = ResizeImage(s.BaseStream, 120)

End If
End Sub
---------------------------------------------------

how would i go about this?

thanks,
Paul
Sep 2 '06 #1
0 875

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

Similar topics

3
by: Dag Eilertsen | last post by:
The script below resizes images into two different sizes. My problem is that the quality of the resized images is poor. Any idea how to improve my script? The users are only uploading jpg's. ...
1
by: John | last post by:
Hi, we have the following problem: in our application v1.0 we have static html pages (+ some javascript). With a CMS (a Content Management System) some "mortal" people can add or expand the...
1
by: toma | last post by:
Hi! I found out how to manipulate (read,resize, etc..) images using System.Drawin namespace from this site: http://authors.aspalliance.com/chrisg/default.asp?category=9 But i don't know how to...
2
by: Earl Teigrob | last post by:
I have written a photo app that allows the administrator to resize photos in an admin panel above the photo on the page. When the the new size is entered, the data is saved into a datastore and the...
6
by: Neo Geshel | last post by:
Greetings. I am making an admin interface, which allows me to upload photos to an access DB. The admin interface also needs to display the uploaded photos, but only needs to show them at a...
6
by: Stephen Edwards | last post by:
I am a novice, so bear with me. I designed a website using CSS TABS, all was fine, then I copy and pasted meta name, etc for keywords, tweaking it where necessary for keywords. I did not notice...
13
by: Casimir Pohjanraito | last post by:
I have a list of links, with a thumbnail image hidden(resized) next to the link. Complete html&css at end of this post. CSS for the link resizes the image on a:hover. All is good, except the...
0
by: Iain | last post by:
Hi I am using Borland Developer 2006, C# web application. Fairly new to the .net platform and very new to repeaters. I have 2 repeaters on a page, both of which are filled from a database....
1
by: swatipriyadarsani | last post by:
hi!!! i m creating website ...i m using ajax.When the page loads..there are 2 combo box one for state and other for city.on select of state city will get populated and on select of city my age will...
4
by: Anna97 | last post by:
Hi, I guess I've built my site sort of strangely: The images are in the html (using tables), but the text is all in css positioned using coordinates (hovering over the images). I need my page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.