/// <summary> /// Overlay Pixel Location to a bitmap /// </summary> /// <param name="image"></param> /// <param name="pixels"></param> public static void OverlayPixels(this Bitmap image, List<PointF> pixels) { LockBitmap lbmp = new LockBitmap(image); for (int iPx = 0; iPx < pixels.Count; iPx++) { int x = (int)(pixels[iPx].X); int y = (int)(pixels[iPx].Y); lbmp.SetPixel(x, y, Color.Red); } lbmp.UnlockBits(); }
/** * Detects the laser in x, y pixel coordinates. * @param debuggingImage - If non-NULL, it will be populated with the processed image that was used to detect the laser locations. * This can be helpful when debugging laser detection issues. * @param laserLocations - Output variable to store the laser locations. * @param maxNumLocations - The maximum number of locations to store in @p laserLocations. * @param thresholdFactor - Scales the laser threshold by this amount. default = 1.0 * @return Returns the number of locations written to @p laserLocations. */ public List <PointF> Process(Bitmap before, Bitmap after, Bitmap debuggingImage) { LockBitmap b = new LockBitmap(before); LockBitmap d = debuggingImage != null ? new LockBitmap(debuggingImage) : null; List <PointF> ret = Process(b, after, d); b.UnlockBits(); if (d != null) { d.UnlockBits(); } return(ret); }
/// <summary> /// Get All the pixels of a Bitmap /// </summary> /// <param name="image"></param> /// <returns></returns> public static List <List <Color> > GetPixels(this Bitmap image) { LockBitmap lbmp = new LockBitmap(image); List <List <Color> > ret = new List <List <Color> >(lbmp.Height); for (int y = 0; y < lbmp.Height; y++) { List <Color> line = new List <Color>(lbmp.Width); for (int x = 0; x < lbmp.Width; x++) { line.Add(lbmp.GetPixel(x, y)); } ret.Add(line); } lbmp.UnlockBits(); return(ret); }
/// <summary> /// Get All the pixels of a Bitmap /// </summary> /// <param name="image"></param> /// <returns></returns> public static List<List<Color>> GetPixels(this Bitmap image) { LockBitmap lbmp = new LockBitmap(image); List<List<Color>> ret = new List<List<Color>>(lbmp.Height); for (int y = 0; y < lbmp.Height; y++) { List<Color> line = new List<Color>(lbmp.Width); for (int x = 0; x < lbmp.Width; x++) line.Add(lbmp.GetPixel(x, y)); ret.Add(line); } lbmp.UnlockBits(); return ret; }
/// <summary> /// Set the row color of a Bitmap /// </summary> /// <param name="image"></param> /// <param name="y"></param> /// <param name="colors"></param> public static void SetRowColors(this Bitmap image, int y, Color[] colors) { LockBitmap lbmp = new LockBitmap(image); for (int x = 0; x < colors.Length; x++) lbmp.SetPixel(x, y, colors[x]); lbmp.UnlockBits(); }
public List<PointF> Process(LockBitmap before, Bitmap after, LockBitmap debuggingImage) { LockBitmap a = new LockBitmap(after); List<PointF> ret = SubProcess(before, a, debuggingImage, m_laserMagnitudeThreshold); a.UnlockBits(); return ret; }
/** * Detects the laser in x, y pixel coordinates. * @param debuggingImage - If non-NULL, it will be populated with the processed image that was used to detect the laser locations. * This can be helpful when debugging laser detection issues. * @param laserLocations - Output variable to store the laser locations. * @param maxNumLocations - The maximum number of locations to store in @p laserLocations. * @param thresholdFactor - Scales the laser threshold by this amount. default = 1.0 * @return Returns the number of locations written to @p laserLocations. */ public List<PointF> Process(Bitmap before, Bitmap after, Bitmap debuggingImage) { LockBitmap b = new LockBitmap(before); LockBitmap d = debuggingImage != null ? new LockBitmap(debuggingImage) : null; List<PointF> ret = Process(b, after, d); b.UnlockBits(); if(d!=null) d.UnlockBits(); return ret; }