Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

k_crysa

@k_crysa
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Flood Fill in C#
    K k_crysa

    I have just started working in c# so I'm not that familiar with it. Still, I need to build a paint program and I am a bit stuck at Flood Fill. I want to be able to fill areas with an undetermined shape, so I used the SetPixel command, but it sets only one pixel (I'm not entirely sure of this). For now, I try to change the color from white to one I pick myself. I call the function in the MouseDown function, and I think it should work. Please help! bmp = new Bitmap(pictureBox1.Width,pictureBox1.Height); private void FloodFill(int x, int y) { bmp.SetPixel(x, y, DrawColor); //sets the color of the pixel to DrawColor I picked pictureBox1.Image = bmp; // assigns the bitmap to the picture box; I work with it to be ale to save the picture if (bmp.GetPixel(x + 1, y) == Color.White) //all four search for each white pixel FloodFill(x + 1, y); if (bmp.GetPixel(x, y + 1) == Color.White) FloodFill(x, y + 1); if (bmp.GetPixel(x - 1, y) == Color.White) FloodFill(x - 1, y); if (bmp.GetPixel(x, y - 1) == Color.White) FloodFill(x, y - 1); return; } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { startPoint.X = e.X; startPoint.Y = e.Y; FloodFill(e.X, e.Y); pictureBox1.Image = bmp; drag = true; }

    C#
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups