Private
Sub GetThumbnail(ByVal
pathToImageFile As
String,
ByVal scaleToPercent
As
Decimal)
' Declare a variable named
imageAjustmentPercent of type Decimal.
Dim imageAdjustmentPercent
As
Decimal
' Divide the scaleToPercent
passed into this method by 100;
' assign the result to the
imageAjustmentPercent variable.
imageAdjustmentPercent = CDec(scaleToPercent
/ 100)
' Declare two variables of type
Integer named
' adjustedImageWidth and
adjustedImageHeight.
Dim adjustedImageWidth,
adjustedImageHeight As
Integer
' Declare a variable named
theImage of type Image.
Dim theImage
As Image
' Get an image object from the
image file;
' assign the image object to
the theImage variable.
theImage =
Image.FromFile(pathToImageFile)
' Calculate adjustedImageWidth
and adjustedImageHeight using the imageAdjustmentPercent.
adjustedImageWidth = CType(theImage.Width
* imageAdjustmentPercent, Integer)
adjustedImageHeight = CType(theImage.Height
* imageAdjustmentPercent, Integer)
' Call the Image class'
GetThumbnail method to create a new scaled
' image object from the
orginal image object. Assign it to theImage varable.
theImage =
theImage.GetThumbnailImage(adjustedImageWidth,
adjustedImageHeight, Nothing,
Nothing)
' Assign theImage to
DemoPicturebox.
Me.DemoPictureBox.Image =
theImage
End
Sub