Aries.IconMethods.IcDvImg.setMaskBitsFromBitmap C# (CSharp) Метод

setMaskBitsFromBitmap() приватный Метод

private setMaskBitsFromBitmap ( Bitmap bm ) : void
bm Bitmap
Результат void
        private void setMaskBitsFromBitmap(Bitmap bm)
        {
            IntPtr hdc = CreateDC("DISPLAY", IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            IntPtr ptr2 = CreateCompatibleDC(hdc);
            DeleteDC(hdc);
            IntPtr hbitmap = bm.GetHbitmap();
            BITMAPINFOHEADER structure = new BITMAPINFOHEADER(this.size, this.colorDepth);
            RGBQUAD rgbquad = new RGBQUAD();
            int cb = structure.biSize + (Marshal.SizeOf(rgbquad) * 2);
            IntPtr ptr = Marshal.AllocCoTaskMem(cb);
            Marshal.WriteInt32(ptr, Marshal.SizeOf(structure));
            Marshal.WriteInt32(ptr, 4, this.size.Width);
            Marshal.WriteInt32(ptr, 8, this.size.Height);
            Marshal.WriteInt16(ptr, 12, (short)1);
            Marshal.WriteInt16(ptr, 14, (short)1);
            Marshal.WriteInt32(ptr, 0x10, 0);
            Marshal.WriteInt32(ptr, 20, 0);
            Marshal.WriteInt32(ptr, 0x18, 0);
            Marshal.WriteInt32(ptr, 0x1c, 0);
            Marshal.WriteInt32(ptr, 0x20, 0);
            Marshal.WriteInt32(ptr, 0x24, 0);
            Marshal.WriteInt32(ptr, 40, 0);
            Marshal.WriteByte(ptr, 0x2c, 0xff);
            Marshal.WriteByte(ptr, 0x2d, 0xff);
            Marshal.WriteByte(ptr, 0x2e, 0xff);
            Marshal.WriteByte(ptr, 0x2f, 0);
            int num2 = this.MaskImageSize(structure);
            IntPtr bits = Marshal.AllocCoTaskMem(num2);
            GetDIBits(ptr2, hbitmap, 0, this.size.Height, bits, ptr, 0);
            Marshal.Copy(bits, this.data, this.MaskImageIndex(structure), num2);
            Marshal.FreeCoTaskMem(bits);
            Marshal.FreeCoTaskMem(ptr);
            DeleteObject(hbitmap);
            DeleteDC(ptr2);
            this.createIcon();
        }