I'm sorry but it looks like every line in that code is wrong. Did you use ChatGPT for that?

It's all in the documentation though. Here's a corrected version:
Code: Select all
CreatePalette(1, #PALETTE_MONOCHROME)
visited = CreateBrush(Nil, 1280, 720, #WHITE, {Depth = 1, Palette = 1, FillPen = 1})
If ReadBrushPixel(visited, 1, 1) = 0 Then DebugPrint("Pixel is black")
If ReadBrushPixel(visited, 1, 1) = 1 Then DebugPrint("Pixel is white")
Explanation: In
CreatePalette() you were passing #PALETTE_MONOCHROME as a color instead of a special inbuilt palette ID. In
CreateBrush() the documentation says that the "color" argument is ignored if you're creating a palette brush and you have to use the "FillPen" tag instead. In the
ReadBrushPixel() lines the documentation says that it will return pen indices for palette brushes so you need to compare against 0 (black) or 1 (white) to find out the pixel color.