/// <summary> /// 共用缓存图片处理委托 /// </summary> /// <param name="bitmap"></param> /// <param name="work"></param> /// <returns></returns> private static T BitmapDelegateWork <T>(Bitmap bitmap, BitmapDelegate <T> work) { Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); BitmapData bitData = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat); IntPtr ptr = bitData.Scan0; int bytes = bitmap.Width * bitmap.Height; byte[] grayValues = new byte[bytes]; Marshal.Copy(ptr, grayValues, 0, bytes); return(work(bitmap, bitData, ptr, bytes, grayValues)); }
public ServerConfig() { InitializeComponent(); updateImageBoxDelegate = new BitmapDelegate(UpdateImageBox); }