From: Samuel on
Significant improvement.

Thank you


"Andrew Morton" <akm(a)in-press.co.uk.invalid> wrote in message
news:7v9jfqFjk1U1(a)mid.individual.net...
> Samuel wrote:
>> I shrink pictures in .NET and the quality of the JPG is very low.
>>
>> Is there anything to do about that?
>
> A couple of points:
>
> 1) Use a pixel format with an alpha channel when resizing, or else you may
> get grey lines at the image borders:
>
> Dim bmp2 As New Bitmap(CInt(targetW), CInt(targetH),
> PixelFormat.Format32bppArgb)
> Dim g As Graphics = Graphics.FromImage(bmp2)
> ' some experimentation may be needed with the InterpolationMode
> g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
>
>
> 2) Use the Image.Save(String, ImageCodecInfo, EncoderParameters) overload,
> which allows you to set the "quality" used when saving a jfif; to get the
> last two parameters:
>
> Dim jpegEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)
> Dim myEncoderParameters As New EncoderParameters(1)
> myEncoderParameters.Param(0) = New
> EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L)
>
>
> ''' <summary>
> ''' Return an ImageEncoder given an ImageFormat.
> ''' </summary>
> ''' <param name="format">An ImageFormat.</param>
> ''' <returns>An ImageEncoder.</returns>
> ''' <remarks></remarks>
> Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo
> For Each codec As ImageCodecInfo In ImageCodecInfo.GetImageEncoders()
> If codec.FormatID = format.Guid Then
> Return codec
> End If
> Next codec
> Return Nothing
> End Function
>
>
> HTH,
>
> Andrew
>