Hi,
Ok I have an image, that is out of proportion to what I want. I want to resize that image, WITHOUT compressing it again, losing file size.
Currently when I do this:
The image seems to look the same but it compresses it. When I run that over an image that is already a 640x480 jpeg, @ 126 KB, it reduces it to 36KB
So I wasnt happy with that and did this:
So when I do this, it spits out an image about the same size, generally a little bigger, thats great, but I cant work resizing into that without it ignoring the encoder stuff and giving me a tiny little file again.
Any help is appreciated!!!!!!!!!!!!!!!!!!!
Thanks
Joshua
Ok I have an image, that is out of proportion to what I want. I want to resize that image, WITHOUT compressing it again, losing file size.
Currently when I do this:
Code:
Dim oImg As Image = Image.FromFile("C:\sourcefile.jpg")
Dim oThumbNail As Image = New Bitmap(640, 480, oImg.PixelFormat)
Dim oGraphic As Graphics = Graphics.FromImage(oThumbNail)
oGraphic.CompositingMode = Drawing2D.CompositingMode.SourceOver
oGraphic.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
oGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
oGraphic.InterpolationMode = Drawing2D.InterpolationMode.Bicubic
oGraphic.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
Dim oRectangle As Rectangle = New Rectangle(0, 0, 640, 480)
oGraphic.DrawImage(oImg, oRectangle)
oThumbNail.Save("C:\test.jpg", Imaging.ImageFormat.Jpeg)
The image seems to look the same but it compresses it. When I run that over an image that is already a 640x480 jpeg, @ 126 KB, it reduces it to 36KB
So I wasnt happy with that and did this:
Code:
Dim myImageCodecInfo As Imaging.ImageCodecInfo
Dim myEncoder As Imaging.Encoder
Dim myEncoderParameter As Imaging.EncoderParameter
Dim myEncoderParameters As Imaging.EncoderParameters
myImageCodecInfo = GetEncoderInfo("image/jpeg")
myEncoder = Imaging.Encoder.Compression
myEncoderParameters = New Imaging.EncoderParameters(1)
myEncoderParameter = New Imaging.EncoderParameter(myEncoder, Imaging.EncoderValue.CompressionNone)
myEncoderParameters.Param(0) = myEncoderParameter
Dim saveImage As Image = Image.FromFile("C:\sourcefile.jpg")
saveImage.Save("C:\test.jpg", myImageCodecInfo, myEncoderParameters)
So when I do this, it spits out an image about the same size, generally a little bigger, thats great, but I cant work resizing into that without it ignoring the encoder stuff and giving me a tiny little file again.
Any help is appreciated!!!!!!!!!!!!!!!!!!!
Thanks
Joshua