Read BMP and then read pixels in the image

I know this should be really simple but I just cant work it out.
I want to load a BMP, then be able to read each pixel and process this to a text file.

the long version is I want to be able to draw a BMP ie in microsoft paint or something easy then process the data(in xojo) so I can use it in an arduino program which outputs the colors to ws2812b (neopixels).
Ideally I want a long narrow BMP ie 8 pixels width by 150 height, and can scroll this over the neopixels, but I just can seem to get xojo to read in a BMP and let me edit or even easily read the pixels…

Picture.Open And than use RGB Surface

Keep in mind that when you have your project set to Retina/HiDPI, Picture.Open returns an immutable bitmap and doesn’t have a Graphics or RGBSurface property. You’ll have to draw the image onto another picture to get access to those pixels.

Immutable Bitmaps do have a RGBSurface but it’s read-only.

At the top of the HiDPI pdf it says

[quote]Immutable Bitmap: A single-representation read-only bitmap. If the bitmap is RGB with 8, 16, 24, or 32 bits per
pixel, there will be a read-only RGBSurface that can be used to access raw pixel data that hasn’t gone through
color conversion or pre-multiplied alpha (typically).[/quote]
However a bit down in the table it lists “Nil” for RGBSurface at Immutable. It should be listed as “valid (read-only)”.

I don’t know RGBSurface but here’s a quit old-skool example just reading the RGB from all pixels.
I use something similar to calculate picture % differences.
Of course you can format the output in any way you need but in this example it’s x,y,R,G,B and “|” as delimiter.

This is using Graphics.Pixel which is now deprecated. Also Graphics.Pixel (and RGBSurface.Pixel) starts at 0 so the loop should be

for y = 0 to pic.Height - 1 for x = 0 to pic.Width - 1

The fact that pic.Graphics.Pixel(pic.Width,y) doesn’t throw out-of-bounds is an error, and it actually returns the color at pic.Graphics.Pixel(0,y+1). The colors for all x in pic.Graphics.Pixel(x,pic.Height) are garbage. Graphics.Pixel does start throwing oob past Width or Height.

RGBSurface doesn’t throw any oob but at least returns solid black.