지정된 색상으로 찾은 첫 번째 픽셀의 점/좌표 (x, y)를 찾아야합니다. GetPixel() 메서드를 사용했지만 너무 느려서 LockBits를 조사하고있었습니다. 어떻게 이것이 실제로 내 문제를 해결할 수 있는지는 알 수 없다. LockBits를 사용하여 발견 된 픽셀의 점을 반환 할 수 있습니까? 여기 색상 반환 지점으로 픽셀 찾기
내 현재 코드입니다 :public Point FindPixel(Image Screen, Color ColorToFind)
{
Bitmap bit = new Bitmap(Screen);
BitmapData bmpData = bit.LockBits(new Rectangle(0, 0, bit.Width, bit.Height),
ImageLockMode.ReadWrite,
PixelFormat.Format32bppPArgb);
unsafe
{
byte* ptrSrc = (byte*)bmpData.Scan0;
for (int y = 0; y < bmpData.Height; y++)
{
for (int x = 0; x < bmpData.Width; x++)
{
Color c = bit.GetPixel(x, y);
if (c == ColorToFind)
return new Point(x, y);
}
}
}
bit.UnlockBits(bmpData);
return new Point(0, 0);
}
정말 고마워요. 정말 잘 됐어요. 지금은 빨리 타오르는군요! :) LockBits로하고 싶은 것을 설명하기 위해 GetPixel()을 사용했습니다. – KLIM8D