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) |