private void setImageBitsFromBitmap(Bitmap bm)
{
IntPtr hdc = CreateDC("DISPLAY", IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
IntPtr ptr2 = CreateCompatibleDC(hdc);
DeleteDC(hdc);
IntPtr hbitmap = bm.GetHbitmap();
BITMAPINFOHEADER bmInfoHeader = new BITMAPINFOHEADER(this.size, this.colorDepth);
int cb = this.XorImageIndex(bmInfoHeader);
int num2 = this.XorImageSize(bmInfoHeader);
IntPtr destination = Marshal.AllocCoTaskMem(cb);
Marshal.Copy(this.data, 0, destination, cb);
Marshal.WriteInt32(destination, 8, bmInfoHeader.biHeight / 2);
IntPtr bits = Marshal.AllocCoTaskMem(num2);
GetDIBits(ptr2, hbitmap, 0, this.size.Height, bits, destination, 0);
Marshal.Copy(bits, this.data, cb, num2);
Marshal.FreeCoTaskMem(bits);
Marshal.FreeCoTaskMem(destination);
DeleteObject(hbitmap);
DeleteDC(ptr2);
this.createIcon();
}