Alsing.Windows.Forms.CoreLib.RegionHandler.ApplyRegion C# (CSharp) Method

ApplyRegion() public method

public ApplyRegion ( ) : void
return void
        public void ApplyRegion()
        {
            var r = new Region(new Rectangle(0, 0, MaskImage.Width, MaskImage.Height));

            for (int y = 0; y < MaskImage.Height; y++)
                for (int x = 0; x < MaskImage.Width; x++)
                {
                    if (MaskImage.GetPixel(x, y) == TransparencyKey)
                    {
                        r.Exclude(new Rectangle(x, y, 1, 1));
                    }
                }

            Control.Region = r;
            Control.BackgroundImage = MaskImage;
        }
    }

Same methods

RegionHandler::ApplyRegion ( Control Target, Bitmap MaskImage, Color TransparencyKey ) : void

Usage Example

示例#1
0
 protected void CreateRegion()
 {
     regionHandler1.ApplyRegion(this, Image, TransparencyKey);
     IsDirty = false;
 }