そうですね、いつでも GDI+ メソッドを使用できます。
Bitmap b = new Bitmap( "some path" );
Color x = b.GetPixel( x, y );
ただし、GetPixel は実際にはかなり遅いです。最初はその方法で試してみてください。ただし、比較的大きな画像を多数スキャンする必要がある場合は、うまくいかない可能性があります。その場合は、LockBits を使用して、連続したメモリ チャンクへのポインタを取得します。その後、画像をすばやくループできますが、ポインターの操作方法を知っている必要がありますが、それほど複雑ではありません。
編集: LockBits を使用して各ピクセルを調べる:
Bitmap b = new Bitmap( "some path" );
BitmapData data = b.LockBits( new Rectangle( 0, 0, b.Width, b.Height ),
ImageLockMode.ReadOnly, b.PixelFormat ); // make sure you check the pixel format as you will be looking directly at memory
unsafe
{
// example assumes 24bpp image. You need to verify your pixel depth
// loop by row for better data locality
for( int y = 0; y < data.Height; ++y )
{
byte* pRow = (byte*)data.Scan0 + y * data.Stride;
for( int x = 0; x < data.Width; ++x )
{
// windows stores images in BGR pixel order
byte r = pRow[2];
byte g = pRow[1];
byte b = pRow[0];
// next pixel in the row
pRow += 3;
}
}
}
b.UnlockBits(data);
画像が最後にパディングされている場合は、BitmapData.Stride プロパティを使用して、新しい各行の先頭に到達できます (そうしないと、がらくたを読み取ることになり、オフセットが厄介になります)。