All pastes #554344 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-10 03:24 UTC
rendered paste body
 public unsafe static Point FindColorHandle(Bitmap Bmp, Color RGB)
        {
            System.Drawing.Imaging.BitmapData BD = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            byte* Index;
            int BPP = 4;
            for (int X = 0; X < Bmp.Width; X++)
            {
                for (int Y = 0; Y < Bmp.Height; Y++)
                {
                    Index = (byte*)BD.Scan0 + (Y * BD.Stride);
                    if (Color.FromArgb(Index[(X * BPP) + 2], Index[(X * BPP) + 1], Index[(X * BPP)]).ToArgb() == RGB.ToArgb())
                    {
                        return new Point(X, Y);
                    }
                }
            }
            Bmp.UnlockBits(BD);
            return new Point(0, 0);
        }