BrightIdeasSoftware.Utilities.ImagelistAdd.Add C# (CSharp) Метод

Add() приватный статический Метод

This method is used to add alphablended images to an imagelist using win32 api functions to overcome the broken .Add() method of the imagelist control which loses the alphablend info of images.
private static Add ( Bitmap bm, ImageList il ) : void
bm System.Drawing.Bitmap Bitmap containing alphablended image.
il System.Windows.Forms.ImageList Imagelist to which the image will be added to.
Результат void
        private static void Add(Bitmap bm, ImageList il)
        {
            IntPtr hBitmap, ppvBits;
            BITMAPINFO bmi = new BITMAPINFO();

            if (bm.Size != il.ImageSize) {	// resize the image to dimensions of imagelist before adding
                bm = new Bitmap(bm, il.ImageSize.Width, il.ImageSize.Height);
            }
            bmi.biSize = 40;			// Needed for RtlMoveMemory()
            bmi.biBitCount = 32;		// Number of bits
            bmi.biPlanes = 1;			// Number of planes
            bmi.biWidth = bm.Width;		// Width of our new bitmap
            bmi.biHeight = bm.Height;	// Height of our new bitmap
            bm.RotateFlip(RotateFlipType.RotateNoneFlipY);	// Required due to the way bitmap is copied
            hBitmap = CreateDIBSection(new IntPtr(0), bmi, 0, out ppvBits, new IntPtr(0), 0);
            BitmapData bitmapData = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            RtlMoveMemory(ppvBits, bitmapData.Scan0, bm.Height * bitmapData.Stride); // copies the bitmap
            bm.UnlockBits(bitmapData);
            ImageList_Add(il.Handle, hBitmap, new IntPtr(0)); // adds the new bitmap to the imagelist control
        }

Same methods

ImagelistAdd::Add ( string pszPath, ImageList il, uint uFlags ) : void