VB graphics

I have 3-dimensional array to store the colour values of pixel of an image. How can I draw the image in VB.NET using the array values as colours for each pixel. I also do want to write it in a separate function rather than a paint event and also need to invoke the method from a another function or event. Pls also tell me how to draw a graphic on a specific component such as picture box without using the picturebox_paint method.

Thanks

manju

[463 byte] By [manjuWicky] at [2007-12-24]
# 1
When the application is loading, create a Bitmap and put your colors in it. Then set the bitmap to the picturebox. This way you won't need to redraw everytime like the picturebox_paint method.
ThE_lOtUs at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
You don't say what your array looks like. I'll just pick something logical. Here's a function to re-create a bitmap from the array:

Private Shared Function CreateBitmap(ByVal pixels(,,) As Byte) As Bitmap
Dim bmp As New Bitmap(pixels.GetLength(0), pixels.GetLength(1))
For x As Integer = 0 To pixels.GetLength(0) - 1
For y As Integer = 0 To pixels.GetLength(1) - 1
Dim c As Color = Color.FromArgb(255, pixels(x, y, 0), pixels(x, y, 1), pixels(x, y, 2))
bmp.SetPixel(x, y, c)
Next
Next
Return bmp
End Function

You can display this bitmap in a PictureBox with:
PictureBox1.Image = CreateBitmap(array)

nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...