---
title: "BitmapViewer Constructor "
canonical: https://www.graphicsmill.com/docs/gm5/C_Aurigma_GraphicsMill_WebControls_BitmapViewer_ctor.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# BitmapViewer Constructor 
 
Creates new instance from 3D array of pixels.
 
**Namespace:** [Aurigma.GraphicsMill.WebControls](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_WebControls.htm.md)
 **Assembly:** Aurigma.GraphicsMill.WebControls (in Aurigma.GraphicsMill.WebControls.dll)
 
## Syntax
  
```
Public Sub New
```
 
```csharp
public BitmapViewer()
```
 
## Examples
 This code demonstrates how to create gradient image from array. ```
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    ' Declare array of RGB pixels with dimensions 128x128
    Dim pixels As Integer(,,)

    ' Do not forget that due Visual Basic syntax you should specify not the 
    ' number of items, but the latest array index. I.e. if we want to create
    ' 128x128 image with 3 channels, we should pass values 127, 127, and 2.
    ReDim pixels(127, 127, 2)

    ' Generate a multiple color gradient
    Dim I, J As Integer
    For I = 0 To pixels.GetLength(0) - 1
        For J = 0 To pixels.GetLength(0) - 1
            pixels(I, J, 0) = 128
            pixels(I, J, 1) = (CDbl(J) / CDbl(pixels.GetLength(0))) * 255
            pixels(I, J, 2) = (CDbl(I) / CDbl(pixels.GetLength(1))) * 255
        Next
    Next

    ' Create new bitmap from this array
    Dim bitmap As New Aurigma.GraphicsMill.Bitmap(pixels, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

    ' Display the bitmap on form.
    Dim g As Graphics
    g = Me.CreateGraphics()

    bitmap.Draw(g, 0, 0, bitmap.Width, bitmap.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Copy, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality)
End Sub
``````csharp
private void button1_Click(object sender, System.EventArgs e)
{// Declare array of RGB pixels with dimensions 128x128int[,,] pixels = new int[128,128,3];// Generate a multiple color gradientint i, j;for (i=0;i < pixels.GetLength(0);i++)	for (j=0;j < pixels.GetLength(1);j++)	{		pixels[i, j, 0] = 128;		pixels[i, j, 1] = (byte)(((double)j / (double)pixels.GetLength(0)) * 255);		pixels[i, j, 2] = (byte)(((double)i / (double)pixels.GetLength(1)) * 255);	}
// Create new bitmap from this arrayAurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(pixels, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);
// Display the bitmap on form.Graphics g = this.CreateGraphics();bitmap.Draw(g, 0, 0, bitmap.Width, bitmap.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Copy, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality);
}
```
   
## See Also

### Reference

- [BitmapViewer Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WebControls_BitmapViewer.htm.md)
- [Aurigma.GraphicsMill.WebControls Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_WebControls.htm.md)
