I need to fill some white pixels in my selFrame image from the bmpOut image. Now, If pixel3 is transparent or empty, it will check all sides of it. If a pixel which is not transparent nor empty is around the pixel, pixel3 will get it's value from pixel2. How can I check if the pixels around pixel3 is transparent or not? Gap of the pixel is max at 10. Here's what I got so far
for (int c = 0; c < selFrame.Width; c++)
for (int j = 0; j < selFrame.Height; j++)
{
var pixel2 = bmpOut.GetPixel(c, j);
var pixel3 = selFrame.GetPixel(c, j);
if (pixel3.ToArgb() == System.Drawing.Color.Transparent.ToArgb() || pixel3.IsEmpty)
{
// do process here
}
}
Updated code
for (int c = 0; c < selFrame.Width; c++)
for (int j = 0; j < selFrame.Height; j++)
{
var pixel2 = bmpOut.GetPixel(c, j);
var pixel3 = selFrame.GetPixel(c, j);
if (pixel3.ToArgb() == System.Drawing.Color.White.ToArgb() || pixel3.IsEmpty)
{
for (int n = 1; n < 20; n++)
{
if (c + n < selFrame.Width && j + n < selFrame.Height)
if (c - n > 0 && j - n > 0)
{
var pix = selFrame.GetPixel(c + n, j + n);
var pix2 = selFrame.GetPixel(c - n, j - n);
if (pix.ToArgb() != System.Drawing.Color.Transparent.ToArgb() || !pix.IsEmpty)
if (pix2.ToArgb() != System.Drawing.Color.Transparent.ToArgb() || !pix2.IsEmpty)
{
selFrame.SetPixel(c, j,pixel2);
MessageBox.Show("q");
}
}
}
}
}
The messagebox is showing, but it is not filling up the white pixels