thephoenix
New member
- Joined
- Apr 19, 2004
- Messages
- 1
I am streaming a resized jpeg and want to change the bit depth to 24 bits. The original jpegs bit depth is 24, but when I stream it, it changes to 32 bits, making the file size larger.
Here is the code:
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(imageUrl)
Dim size As System.Drawing.Size
Dim iwidth As Integer = 500
Dim iheight As Integer = 500
If image.Width > iwidth Then
size = New System.Drawing.Size(iwidth, (iwidth / image.Width) * image.Height)
Else
size = New System.Drawing.Size(image.Width, image.Height)
End If
Dim ibitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(size.Width, size.Height)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ibitmap)
g.InterpolationMode = Drawing.Drawing2D.InterpolationMode.Bicubic
g.CompositingMode = Drawing.Drawing2D.CompositingMode.SourceOver
g.CompositingQuality = Drawing.Drawing2D.CompositingQuality.Default
g.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
g.Clear(System.Drawing.Color.Blue)
g.DrawImage(image, New System.Drawing.Rectangle(0, 0, ibitmap.Width, ibitmap.Height), New System.Drawing.Rectangle(0, 0, image.Width, image.Height), System.Drawing.GraphicsUnit.Pixel)
ibitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
ibitmap.Dispose()
g.Dispose()
image.Dispose()
THX
Here is the code:
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(imageUrl)
Dim size As System.Drawing.Size
Dim iwidth As Integer = 500
Dim iheight As Integer = 500
If image.Width > iwidth Then
size = New System.Drawing.Size(iwidth, (iwidth / image.Width) * image.Height)
Else
size = New System.Drawing.Size(image.Width, image.Height)
End If
Dim ibitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(size.Width, size.Height)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ibitmap)
g.InterpolationMode = Drawing.Drawing2D.InterpolationMode.Bicubic
g.CompositingMode = Drawing.Drawing2D.CompositingMode.SourceOver
g.CompositingQuality = Drawing.Drawing2D.CompositingQuality.Default
g.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
g.Clear(System.Drawing.Color.Blue)
g.DrawImage(image, New System.Drawing.Rectangle(0, 0, ibitmap.Width, ibitmap.Height), New System.Drawing.Rectangle(0, 0, image.Width, image.Height), System.Drawing.GraphicsUnit.Pixel)
ibitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
ibitmap.Dispose()
g.Dispose()
image.Dispose()
THX