This documentation is for the old version. Go to the latest Graphics Mill docs

BitmapViewer Constructor

Creates new instance from 3D array of pixels.

Namespace: Aurigma.GraphicsMill.WebControls
Assembly: Aurigma.GraphicsMill.WebControls (in Aurigma.GraphicsMill.WebControls.dll)

Syntax

Visual Basic
Public Sub New
C#
public BitmapViewer()

Examples

This code demonstrates how to create gradient image from array.
Visual Basic

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
C#

private void button1_Click(object sender, System.EventArgs e)
{
	// Declare array of RGB pixels with dimensions 128x128
	int[,,] pixels = new int[128,128,3];
	
	// Generate a multiple color gradient
	int 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 array
	Aurigma.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