CSharpGL.BitmapFiller.Fill C# (CSharp) Метод

Fill() публичный Метод

build texture's content with Bitmap.
public Fill ( ) : void
Результат void
        public override void Fill()
        {
            // generate texture.
            if (target == TextureTarget.Texture1D)
            {
                Bitmap bmp = null;
                for (int level = 0; level <= this.maxLevel; level++)
                {
                    if (level == 0) { bmp = this.bitmap; }
                    else
                    {
                        bmp.Dispose();
                        int width = bmp.Width / 2;
                        if (width < 1) { width = 1; }
                        bmp = new Bitmap(bmp, width, 1);
                    }
                    //  Lock the image bits (so that we can pass them to OGL).
                    BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
                        ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                    OpenGL.TexImage1D((uint)target, level, this.internalformat, bitmap.Width, 0, this.format, this.type, bitmapData.Scan0);
                    //  Unlock the image.
                    bmp.UnlockBits(bitmapData);
                }

                if (bmp != this.bitmap) { bmp.Dispose(); }
            }
            else if (target == TextureTarget.Texture2D)
            {
                Bitmap bmp = null;
                for (int level = 0; level <= this.maxLevel; level++)
                {
                    if (level == 0) { bmp = this.bitmap; }
                    else
                    {
                        bmp.Dispose();
                        int width = bmp.Width / 2, height = bmp.Height / 2;
                        if (width < 1) { width = 1; }
                        if (height < 1) { height = 1; }
                        bmp = new Bitmap(bmp, width, height);
                    }
                    //  Lock the image bits (so that we can pass them to OGL).
                    BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
                        ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                    OpenGL.TexImage2D((uint)target, level, this.internalformat, bmp.Width, bmp.Height, 0, this.format, this.type, bitmapData.Scan0);
                    //  Unlock the image.
                    bmp.UnlockBits(bitmapData);
                }

                if (bmp != this.bitmap) { bmp.Dispose(); }
            }
            else
            { throw new NotImplementedException(); }
        }