Given the name of a file we will determine the width and height parameters of an image.
Let us assume that our file image is /images/kennet_avon_canal.jpg and that we are going to illustrate the information we have found by using a label control lblRandomImage.
To begin with our imports. At the very least we will need
Imports System.Drawing
We will also define the parameters which we will be using
Dim RandomImage As Bitmap
Dim Width As Integer
Dim Height As Integer
And assign our discovered values, after creating RandomImage as a new Bitmap.
RandomImage = New Bitmap(Server.MapPath(strImageName))
Height = RandomImage.Height
Width = RandomImage.Width
Finally we will set the discovered width and height parameters of the image, plus the image itself, as the text parameter of our label control.
lblRandomImage.Text = "<DIV><IMG height= src=""" & RandomImage & """ width=""" & width & """ height= """ & height&"""></DIV>"
lblRandomImage.Text = lblRandomImage.Text +"<DIV>Width = " & Width& "></DIV>"
lblRandomImage.Text = lblRandomImage.Text + "<DIV>Height = " & Height & "></DIV>"
NAT January 2006
| This article viewed: 833 times | Back |
Copyright © 2004-2007 Janet Systems Ltd.