.net creating broken jpegs in IE and FF

It drives me crazy, so ...

When resizing an image to a small thumbnail, the resulting image cannot be fully displayed by IE and FF. Opera shows the image correctly, as well as previewing images in Windows.

This is the resizing code snippet:

     final_image = New System.Drawing.Bitmap(92, 110)
     graphic = System.Drawing.Graphics.FromImage(final_image)
     graphic.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.Color.White), New System.Drawing.Rectangle(0, 0, 92, 110))
     graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
     graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
     graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
     graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
     graphic.DrawImage(original_image, 0, 0, 92, 110)

     Dim info() As Drawing.Imaging.ImageCodecInfo = Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
     Dim encoderParameters As Drawing.Imaging.EncoderParameters
     encoderParameters = New Drawing.Imaging.EncoderParameters(1)
     encoderParameters.Param(0) = New Drawing.Imaging.EncoderParameter(Drawing.Imaging.Encoder.Quality, 100L)

Result:

This image must be missing, it is less than 1/6 in FF3 and IE6 / 7 http://incito.hr/e387103c-b12f-4324-ac2d-a836e65a6bad-92x110.jpg

If your browser displays the image correctly (screen capture from FF3):

Screen capture with FF3 http://incito.hr/Clipboard02.png

However, if I increase the size of the thumbnails to 126x150, everything will be fine, in all browsers:

The same image, modified by the same code, up to 126x150 http://incito.hr/4d51a5cd-621e-4709-b24a-ebb8f9da54dd-126x150.jpg

+3
3

EOI .

- , , EOI JPG .

wiki page EOI .

+3

, Flush Graphics, :

graphic.Flush();

, , .

0

Save Flush, , Earwicker.

0

Source: https://habr.com/ru/post/1711551/


All Articles