Author: jackson
Date: 2007-04-04 17:19:46 -0400 (Wed, 04 Apr 2007)
New Revision: 75409
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs
Log:
* Picture.cs: Correct twips calculation.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
2007-04-04 20:15:31 UTC (rev 75408)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
2007-04-04 21:19:46 UTC (rev 75409)
@@ -1,3 +1,7 @@
+2007-04-04 Jackson Harper <[EMAIL PROTECTED]>
+
+ * Picture.cs: Correct twips calculation.
+
2007-03-27 Jackson Harper <[EMAIL PROTECTED]>
* RTF.cs: Use the documents encoding code page to decode unicode
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs
2007-04-04 20:15:31 UTC (rev 75408)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs
2007-04-04 21:19:46 UTC (rev 75409)
@@ -37,8 +37,16 @@
private byte [] data;
private float width = -1;
private float height = -1;
-
+ private readonly static float dpix;
+
+ static Picture ()
+ {
+ Bitmap b = new Bitmap (1, 1);
+ Graphics g = Graphics.FromImage (b);
+ dpix = g.DpiX;
+ }
+
public Picture ()
{
@@ -87,14 +95,14 @@
public void SetWidthFromTwips (int twips)
{
- width = (twips * 144) / 254;
+ width = (int) (((float) twips / 1440.0F) * dpix + 0.5F);
}
public void SetHeightFromTwips (int twips)
{
- height = (twips * 144) / 254;
+ height = (int) (((float) twips / 1440.0F) * dpix +
0.5F);
}
-
+
//
// Makes sure that we got enough information to actually use
the image
//
@@ -130,7 +138,6 @@
public Image ToImage ()
{
- Console.WriteLine ("CREATING IMAGE: {0}", data.Length);
return Image.FromStream (new MemoryStream (data));
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches