[Mono-bugs] [Bug 381169] System.Drawing.Image and png resolution

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Apr 18 08:45:21 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=381169

User spouliot at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=381169#c1


Sebastien Pouliot <spouliot at novell.com> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |spouliot at novell.com
         AssignedTo|mono-bugs at lists.ximian.com                      |spouliot at novell.com
             Status|NEW                                             |ASSIGNED




--- Comment #1 from Sebastien Pouliot <spouliot at novell.com>  2008-04-18 06:45:21 MST ---
The issue is not identical to the JPEG case as the libgdiplus PNG coded already
reads the resolution from the bitmap.

>From pngcodec.c:
        bitmap_data->image_flags |= ImageFlagsHasRealDPI;
        bitmap_data->dpi_horz = png_get_x_pixels_per_inch(png_ptr, info_ptr);
        bitmap_data->dpi_vert = png_get_y_pixels_per_inch(png_ptr, info_ptr);

>From libpng web site:
<quote>(Each of these returns 0 [signifying "unknown"] if the data is not
present or if res_x is 0; res_x_and_y is 0 if res_x != res_y)</quote>

Now it looks like (see sample code) that MS returns the screen resolution when
the PNG file has none.


using System;
using System.Drawing;

class Program {
        static void Main (string [] args)
        {
                using (Bitmap bmp = new Bitmap ("mono.png")) {
                        Console.WriteLine (bmp.HorizontalResolution);
                        Console.WriteLine (bmp.VerticalResolution);

                        using (Graphics g = Graphics.FromImage (bmp)) {
                                Console.WriteLine (g.DpiX);
                                Console.WriteLine (g.DpiY);
                        }
                }
        }
}


Under MS.NET
72.009
72.009
72.009
72.009

Under Mono
0
0
86
86


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list