D
D
Denis2021-04-10 10:46:16
C++ / C#
Denis, 2021-04-10 10:46:16

How to get pixel color by coordinates on Panel?

The point is in the title. We need to find the color of a pixel at certain coordinates on the PANEL and not on the pictureBox. I found there is one in winAPI, BitBlt which does it pretty badly. For example, I can pass coordinates to this function, and it will find the color of a pixel by other coordinates. I could bi-calibrate, but is it worth it? What bi were crutches. In general, if someone knows - write. Bitblt example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cicatrix, 2021-04-10
Folyush @AAGR

Get the panel image:

private static Image PanelToBitmap(Control pnl) {
    var bmp = new Bitmap(pnl.Width, pnl.Height);
    pnl.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
    return bmp;
}

Getting a pixel from an image:
Bitmap.GetPixel()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question