hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.67k stars 1.17k forks source link

Get Pixel Colour #273

Closed Kaktuar closed 7 years ago

Kaktuar commented 7 years ago

I'm looking to find a way of getting the colour of a specific pixel on the matrix e.g int GetPixel(int x, int y);

What would be the best way to approach this?

hzeller commented 7 years ago

Write a wrapper canvas, that delegates to the underlying RGBMatrix canvas, but also stores the color you set at a particular position. With that, you can then implement a GetPixel() function, as you have stored the color locally.

It is not very easy to get the color out of the original canvas, as it is deconstructed and prepared in memory for the display activity. So having storing it in its original form as described above is the best.