public unsafe static Rectangle getRectangle(Bitmap b) { Rectangle rct = new Rectangle(); rct.Width = 40; rct.Height = 40; int x = 0; int y = 0; BitmapData bmd = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, b.PixelFormat); int pixelSize = GetBitsPerPixel(b.PixelFormat);//gets the number of bits per pixel for (int j = 0; j < bmd.Height; j++) { byte* row = (byte*)bmd.Scan0 + (j * bmd.Stride); for (int i = 0; i < bmd.Stride; i++) { int offSet = i * pixelSize; byte blue = row[offSet];//here i get the error!!!! byte green = row[offSet + 1]; byte red = row[offSet + 2]; if ((green > 0) && (blue> 0) && (red > 0)) { x = i; y = j; } } } rct.X = x; rct.Y = y; return rct; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)