Dim bmp As Bitmap = New Bitmap("C:\Users\c3301\Desktop\image.png") Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height) Dim bmpData As BitmapData = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb) Dim ptr As IntPtr = bmpData.Scan0 Dim bytes As Integer = Math.Abs(bmpData.Stride) * bmp.Height Dim rgbValues(bytes - 1) As Byte Marshal.Copy(ptr, rgbValues, 0, bytes) ' Retrieve RGB values Dim RedValue As Int32 Dim GreenValue As Int32 Dim BlueValue As Int32 Dim l As Integer = 0 For x = 0 To bmp.Width - 1 For y = 0 To bmp.Height - 1 l = ((bmp.Width * 3 * y) + (x * 3)) RedValue = rgbValues(l) GreenValue = rgbValues(l + 1) BlueValue = rgbValues(l + 2) ListBox1.Items.Add(RedValue & ", " & GreenValue & ", " & BlueValue) Next Next bmp.UnlockBits(bmpData)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)