Sub Camera1_PictureTaken (Data() As Byte)
Dim In As InputStream
In.InitializeFromBytesArray(Data, 0, Data.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
In.Close
Dim x As Int, y As Int, z As Int
Dim numPix As Long
Dim PixelColor As Int
numPix = bmp.Height * bmp.Width
Dim res(4) As Int
Dim ARGB(4) As Long
For x = 0 To bmp.Width - 1
For y = 0 To bmp.Height - 1
PixelColor = bmp.GetPixel(x,y)
res(0) = Bit.UnsignedShiftRight(Bit.And(PixelColor, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.And(PixelColor, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.And(PixelColor, 0xff00), 8)
res(3) = Bit.And(PixelColor, 0xff)
' Log("ARGB = " & res(0) & "," & res(1) & "," & res(2) & "," & res(3))
For z = 0 To 3
ARGB(z) = ARGB(z) + res(z)
Next
Next
Log("Line " & x & " / " & bmp.Height)
Next
For z = 0 To 3
ARGB(z) = ARGB(z) / numPix
Next
End Sub