Author: pbartok
Date: 2006-01-19 18:53:38 -0500 (Thu, 19 Jan 2006)
New Revision: 55801
Modified:
trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing/Icon.cs
Log:
2006-01-19 Peter Dennis Bartok <[EMAIL PROTECTED]>
* Icon.cs: The code wrongly assumed that the stride for the icon
would be the same as the stride for the bitmap. This was causing
memory corruption.
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-01-19
22:25:21 UTC (rev 55800)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-01-19
23:53:38 UTC (rev 55801)
@@ -1,3 +1,9 @@
+2006-01-19 Peter Dennis Bartok <[EMAIL PROTECTED]>
+
+ * Icon.cs: The code wrongly assumed that the stride for the icon
+ would be the same as the stride for the bitmap. This was causing
+ memory corruption.
+
2006-01-18 Peter Dennis Bartok <[EMAIL PROTECTED]>
* Icon.cs: Reworked ToBitmap() method to not use Bitmap(Stream)
Modified: trunk/mcs/class/System.Drawing/System.Drawing/Icon.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Icon.cs 2006-01-19
22:25:21 UTC (rev 55800)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Icon.cs 2006-01-19
23:53:38 UTC (rev 55801)
@@ -325,6 +325,7 @@
BitmapData bits;
ColorPalette pal;
int biHeight;
+ int bytesPerLine;
if (imageData == null) {
return new Bitmap(32, 32);
@@ -376,10 +377,11 @@
}
}
+ bytesPerLine = (int)((((bih.biWidth * bih.biBitCount) +
31) & ~31) >> 3);
bits = bmp.LockBits(new Rectangle(0, 0, bmp.Width,
bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
for (int y = 0; y < biHeight; y++) {
- Marshal.Copy(ii.iconXOR, bits.Stride * y,
(IntPtr)((int)bits.Scan0 + bits.Stride * (biHeight - 1 - y)), bits.Stride);
+ Marshal.Copy(ii.iconXOR, bytesPerLine * y,
(IntPtr)((int)bits.Scan0 + bits.Stride * (biHeight - 1 - y)), bytesPerLine);
}
bmp.UnlockBits(bits);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches