Nevron .NET Vision
Framework / Presentation Layer / Graphics / Appearance Styles / Fill Styles / Image Fill Style

In This Topic
    Image Fill Style
    In This Topic

    The image fill style is used to fill an object interior with a raster image. It is represented by an instance of the NImageFillStyle class. The following code applies the myimage.png file as filling:

    C#
    Copy Code
    someObject.FillStyle = new NImageFillStyle("c:\\images\\myimage.png");
    
    Visual Basic
    Copy Code
    someObject.FillStyle = new NImageFillStyle("c:\\images\\myimage.png");
    
     Creating Images Dynamically

    You may also create the image dynamically using the functionality provided by the Graphics.FromImage function. In the following example the image is created on the fly and passed to the NImageFillStyle constructor:

    C#
    Copy Code
    // create objects
    Bitmap bitmap = new Bitmap(256, 256, PixelFormat.Format32bppArgb);
    Graphics graphics = Graphics.FromImage(bitmap);
    Pen pen = new Pen(Color.Black, 1);
    
    graphics.Clear(Color.White);
    graphics.DrawRectangle(pen, 10, 10, 236, 236);
    
    // dispose objects
    pen.Dispose();
    graphics.Dispose();
    
    someObject.FillStyle = new NImageFillStyle(bitmap);
    
    Visual Basic
    Copy Code
    ' create objects
    Dim bitmap As New Bitmap(256, 256, PixelFormat.Format32bppArgb)
    Dim graphics As Graphics = graphics.FromImage(bitmap)
    Dim pen As New Pen(Color.Black, 1)
    
    Graphics.Clear(Color.White)
    graphics.DrawRectangle(pen, 10, 10, 236, 236)
    
    ' dispose objects
    pen.Dispose()
    graphics.Dispose()
    
    someObject.FillStyle = New NImageFillStyle(bitmap)
    
     Modifying the Alpha Channel

    Another useful feature of the image fill style is that it can also modify the alpha channel of the image:

    C#
    Copy Code
    someObject.FillStyle = new NImageFillStyle("c:\\images\\myimage.png", 125);
    
    Visual Basic
    Copy Code
    someObject.FillStyle = new NImageFillStyle("c:\\images\\myimage.png", 125);
    

    The above code will apply a semi transparent raster filling on the object based on the raster image contained in the myimage.png.

    See Also