Thanks fro the response. This does save the file as a .PNG, but it makes it an image with a filesize 10x larger than the original. It turns a 50k jpg into a 500k png and a 5k gif into a 50k png. Any idea why?
Dim SourceBitmap As Bitmap = New Bitmap(Server.MapPath(savePath & "original." & c))
Dim TargetBitmap As Bitmap = New Bitmap(NewWidth,NewHeight)
Dim g As Graphics = Graphics.FromImage(TargetBitmap)
' set Drawing Quality
g.InterpolationMode = InterpolationMode.HighQualityBicubic
g.SmoothingMode = SmoothingMode.HighQuality
g.Clear(Color.White)
Dim compressionRectangle As Rectangle = New Rectangle(0,0,NewWidth,NewHeight)
g.DrawImage(SourceBitmap, compressionRectangle)
g.DrawString("TEST PNG",New Font("Verdana Bold", 10),New SolidBrush(Color.SteelBlue),10,10)
Response.ContentType = "image/png"
' decide new path and save the image
Dim NewImagePath As String = System.IO.Path.GetFileNameWithoutExtension(OriginalImageName) + ".png"
'dim memStream As New MemoryStream((Request.MapPath("/images/TESTPNG/") &"LARGE.png"))
TargetBitmap.Save((Request.MapPath("\images\TESTPNG\") &"LRG.png"),ImageFormat.Png)
'TargetBitmap.Save(memStream,ImageFormat.Png)
'memStream.WriteTo(response.outputstream)
'tidy up
TargetBitmap.dispose()
gregfnor
Contributor
2127 Points
465 Posts
Re: Saving to PNG SAMPLE
Apr 03, 2004 10:31 PM|LINK
Dim SourceBitmap As Bitmap = New Bitmap(Server.MapPath(savePath & "original." & c)) Dim TargetBitmap As Bitmap = New Bitmap(NewWidth,NewHeight) Dim g As Graphics = Graphics.FromImage(TargetBitmap) ' set Drawing Quality g.InterpolationMode = InterpolationMode.HighQualityBicubic g.SmoothingMode = SmoothingMode.HighQuality g.Clear(Color.White) Dim compressionRectangle As Rectangle = New Rectangle(0,0,NewWidth,NewHeight) g.DrawImage(SourceBitmap, compressionRectangle) g.DrawString("TEST PNG",New Font("Verdana Bold", 10),New SolidBrush(Color.SteelBlue),10,10) Response.ContentType = "image/png" ' decide new path and save the image Dim NewImagePath As String = System.IO.Path.GetFileNameWithoutExtension(OriginalImageName) + ".png" 'dim memStream As New MemoryStream((Request.MapPath("/images/TESTPNG/") &"LARGE.png")) TargetBitmap.Save((Request.MapPath("\images\TESTPNG\") &"LRG.png"),ImageFormat.Png) 'TargetBitmap.Save(memStream,ImageFormat.Png) 'memStream.WriteTo(response.outputstream) 'tidy up TargetBitmap.dispose()Thanks