Author: jackson
Date: 2007-04-16 13:53:03 -0400 (Mon, 16 Apr 2007)
New Revision: 75783

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs
Log:

                * RTF.cs:
        * Picture.cs: Save a step by loading the image data directly
        * into
        the picture's memory stream. (Aprox 15% speedup).



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-16 17:30:32 UTC (rev 75782)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog    
2007-04-16 17:53:03 UTC (rev 75783)
@@ -1,3 +1,9 @@
+2007-04-16  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * RTF.cs:
+       * Picture.cs: Save a step by loading the image data directly into
+       the picture's memory stream. (Aprox 15% speedup).
+
 2007-04-05  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * RTF.cs: Use the "goal" width and height to compute the metafile size

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-16 17:30:32 UTC (rev 75782)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/Picture.cs   
2007-04-16 17:53:03 UTC (rev 75783)
@@ -34,7 +34,7 @@
 
                private Minor image_type;
                private Image image;
-               private byte [] data;
+               private MemoryStream data;
                private float width = -1;
                private float height = -1;
 
@@ -57,9 +57,12 @@
                        set { image_type = value; }
                }
 
-               public byte [] Data {
-                       get { return data; }
-                       set { data = value; }
+               public MemoryStream Data {
+                       get {
+                               if (data == null)
+                                       data = new MemoryStream ();
+                               return data;
+                       }
                }
 
                public float Width {
@@ -138,7 +141,7 @@
 
                public Image ToImage ()
                {
-                       return Image.FromStream (new MemoryStream (data));
+                       return Image.FromStream (data);
                }
        }
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs       
2007-04-16 17:30:32 UTC (rev 75782)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs       
2007-04-16 17:53:03 UTC (rev 75783)
@@ -947,7 +947,8 @@
 
                                if (read_image_data && rtf.rtf_class == 
TokenClass.Text) {
 
-                                       ArrayList image_data = new ArrayList ();
+                                       picture.Data.Seek (0, SeekOrigin.Begin);
+
                                        char c = (char) rtf.major;
 
                                        uint digitValue1;
@@ -997,7 +998,7 @@
                                                else 
                                                        break;
 
-                                               image_data.Add ((byte) checked 
(digitValue1 * 16 + digitValue2));
+                                               picture.Data.WriteByte ((byte) 
checked (digitValue1 * 16 + digitValue2));
 
                                                // We get the first hex digit 
at the end, since in the very first
                                                // iteration we use rtf.major 
as the first hex digit
@@ -1009,7 +1010,6 @@
 
                                        
                                        read_image_data = false;
-                                       picture.Data = (byte []) 
image_data.ToArray (typeof (byte));
                                        break;
                                }
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to