Main issue I'm seeing is you're not reading the pixel from the right spot. The snapshot size won't be the same size as the drawingCanvas unless the window isn't resized or if the drawing canvas' resolution mode is set to fixed, and the resolution is the same size as the canvas.
Anyways, a fix would be to convert the coordinates. Instead of
x = Mouse.X*DrawingCanvas.SnapshotWidth/DrawingCanvas.Width
y = Mouse.Y*DrawingCanvas.SnapshotHeight/DrawingCanvas.Height
or if the drawing canvas isn't positioned at the top left of the layout:
x = (Mouse.X-DrawingCanvas.BBoxLeft)*DrawingCanvas.SnapshotWidth/DrawingCanvas.Width
y = (Mouse.Y-DrawingCanvas.BboxTop)*DrawingCanvas.SnapshotHeight/DrawingCanvas.Height
https://www.dropbox.com/scl/fi/c9zekz1ru5pzw6u26mxon/read_pixels.c3p?rlkey=haodeqfz3vknri1qz8db4c5bm&st=b0zkb50o
EDIT:
Looks like these three expressions are approximately the same. So you could just divide the mouse position by the pixelScale. The fact that all three aren't all the same is another c3 issue but shouldn't matter too much.
DrawingCanvas.SnapshotWidth/DrawingCanvas.Width
DrawingCanvas.SnapshotHieght/DrawingCanvas.Height
1/DrawingCanvas.PixelScale
Edit2:
If you manually set the fixed resolution mode size, then don't use pixelScale.
Works like a charm, thanks!