Converting BMP to JPG loses quality
I'm a little new at ASP.Net, so bear with me. I have a page where users upload bitmaps to my site. I then convert them to JPGs of the same size and destroy the bitmaps. In doing so, they lose color quality a little and become a little blurry. Is there any way around this? Here is my code:
VB Code:
<% ' import all relevant namespaces %>
<%@ Page Debug="true" %>
<%@ import namespace="System" %>
<%@ import namespace="System.Drawing" %>
<%@ import namespace="System.Drawing.Imaging" %>
<%@ import namespace="System.IO" %>
<script runat="server" >
Sub ConvertFile()
' create New image and bitmap objects. Load the image file and put into a resized bitmap.
Dim g As System.Drawing.Image = System.Drawing.Image.FromFile(Request.Form("src"))
Dim imgOutput
If Request.Form("Thumbnail") > "" Then
imgOutput = New Bitmap(g, 130, 90)
Else
imgOutput = New Bitmap(g)
End If
' Set the contenttype
Response.ContentType = "image/jpeg"
' send the converted image to the viewer
imgOutput.save(Response.OutputStream, system.drawing.imaging.imageformat.JPEG) ' output to the user
' tidy up
g.dispose()
imgOutput.dispose()
End Sub
</script>
<%
' make sure Nothing has gone to the client
Response.Clear
Call ConvertFile()
Response.End
%>
Well, it wasn't quite 100%, but
It was a lot closer. Thanks, Cander.