Last post May 11, 2005 08:11 AM by SomeNewKid
May 08, 2005 01:31 AM|digitalMind|LINK
Hi... I have a question about resize images...
First... I have this code...
(The SWF Image inside isn't important... Don't care...)
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing" %>
Dim uploadSucess As Boolean
Dim strFileName As String
Dim filepath as String
Sub btnUpload_Click(sender As Object, e As EventArgs)
uploadSucess = uploadMainImage()
If (uploadSucess) Then
'Check to make sure we actually have a file to upload
If Not (fileupload1.PostedFile Is Nothing) Then
Dim strLongFilePath As String = fileupload1.PostedFile.FileName
Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "\")
strFileName = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)
Select Case fileupload1.PostedFile.ContentType
'Make sure we are getting a valid JPG image
Case "image/pjpeg", "image/jpeg", "image/pbmp", "image/bmp", "image/pgif", "image/gif"
filepath = "c:\upup\thumbs\"
fileupload1.PostedFile.SaveAs(filepath & strFileName)
'Not a valid jpeg image
lblMsg.Text = "Not a valid jpeg image"
'Create a new Bitmap Image loading from location of origional file
Dim bm as Bitmap = System.Drawing.Image.FromFile(filePath & strFileName)
'Declare Thumbnails Height and Width
Dim newWidth as Integer = 200
Dim newHeight as Integer = (newWidth/bm.width)*bm.Height
'Create the new image as a blank bitmap
Dim resized as Bitmap = new Bitmap(newWidth,newHeight)
'Create a new graphics object with the contents of the origional image
Dim g as Graphics = Graphics.FromImage(resized)
'Resize graphics object to fit onto the resized image
g.DrawImage(bm, new Rectangle
'Get rid of the evidence
'Create new path and filename for the resized image
Dim newStrFileName as String = FilePath & "T_" & strFileName
'Save the new image to the same folder as the origional
<form runat="server" form-data="form-data" multipart="multipart">
<p class="NormalBold" align="center">
Browse for Image:</td>
<input id="fileUpload1" type="file" size="30" runat="server" /></td>
<asp:Button id="btnUpload" onclick="btnUpload_Click" runat="server" Text="Upload
<asp:Label id="lblMsg" runat="server"></asp:Label>
<param name="movie" value="result.swf">
<param name="quality" value="high">
<embed src="result.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="550" height="400"></embed>
The question is...
How can I create an image with better quality...?
Just rewriting this code... Not working with C++ or other language... Because I don't understand them and usually I have to install some files into the server... or buy some software...
And... What else can I do to images using this language...?
May 10, 2005 11:12 PM|digitalMind|LINK
Anybody have little idea about this..?? At least one word... [8-)]
May 10, 2005 11:32 PM|SomeNewKid|LINK
Here is a series of articles that I have found very helpful:
GDI+ / System.Drawing Articles by Chris Garrett
You will see that the first article talks about controlling the quality of an image through its compression.
Down-sampling images can sometimes result in slightly blurred images. If you find this to be the case, you may need to not only control the compression level, but also apply a little sharpening to the resulting image. Another of the listed articles shows
how to sharpen an image.
If you're doing a lot of image manipulation, you may wish to check out the following:
GotDotNet User Sample: DevIL Image Library
I have not yet used the DevIL Image Library, so I cannot vouch for it. However, it is in my collection of GDI+ resources, so I figured I may as well pass it along to you.
I hope this helps.
May 11, 2005 05:47 AM|digitalMind|LINK
GREAT..! Thanks SomeNewKid... Just what I was looking for... [<:o)]
Everyday I feel that ASP.NET is more and more amazing..... [:D]
THANKS YOU... THANKS YOU....
THANKS ASP.NET TOO.... [:D]
I'm sooooo happy.... Like a child with a sweet.... Like a dog with a bone.... Like... well... You know... [:P]
May 11, 2005 08:11 AM|SomeNewKid|LINK