日期:2014-05-17 浏览次数:20962 次
public sealed class ImageList : Component
{
private ImageList owner;
public Image this[int index]
{
get
{
if ((index < 0)
------解决方案--------------------
(index >= this.Count))
{
throw new ArgumentOutOfRangeException("index", SR.GetString("InvalidArgument", new object[] { "index", index.ToString(CultureInfo.CurrentCulture) }));
}
return this.owner.GetBitmap(index);
}
set ......
}
......
}
private Bitmap GetBitmap(int index)
{
if ((index < 0)
------解决方案--------------------
(index >= this.Images.Count))
{
throw new ArgumentOutOfRangeException("index", SR.GetString("InvalidArgument", new object[] { "index", index.ToString(CultureInfo.CurrentCulture) }));
}
Bitmap image = null;
if (this.ColorDepth == ColorDepth.Depth32Bit)
{
NativeMethods.IMAGEINFO pImageInfo = new NativeMethods.IMAGEINFO();
if (SafeNativeMethods.ImageList_GetImageInfo(new HandleRef(this, this.Handle), index, pImageInfo))
{
Bitmap bitmap2 = null;
BitmapData bmpData = null;
BitmapData targetData = null;
IntSecurity.ObjectFromWin32Handle.Assert();
try
{
&nbs