• 大小: 76KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-06
  • 语言: C#
  • 标签: 区域填充  活性边表  

资源简介

C# winform VS2013项目实现的去油填充-活性边表

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 活性边表
{
    public partial class Form1 : Form
    {
        Bitmap bmp;
        Graphics graphics;
        void MidpointLine(int x0 int y0 int x1 int y1)
        {

            //bmp = new Bitmap(pictureBox1 .Width pictureBox1 .Height );

            //Graphics graphics = Graphics.FromImage(bmp);            

            int a b delta1 delta2 d x y;
            int xf xs yf ys;
            if ((x1 - x0) != 0 && (float)(y1 - y0) / (float)(x1 - x0) >= 0)
            {
                xs = x1 > x0 ? x0 : x1;
                xf = x1 + x0 - xs;
                ys = y1 > y0 ? y0 : y1;
                yf = y1 + y0 - ys;
                if ((float)((yf - ys) / (xf - xs)) <= 1)
                {
                    y0 = ys;
                    y1 = yf;
                    x0 = xs;
                    x1 = xf;
                    a = y0 - y1;
                    b = x1 - x0;
                    d = 2 * a + b;
                    delta1 = 2 * a;
                    delta2 = 2 * (a + b);
                    x = x0;
                    y = y0;
                    bmp.SetPixel(x y Color.Black); //方法2
                    //g.DrawLine(new Pen(Color.Green) x bmp.Height - y  x+1 bmp.Height - y);//方法3
                    while (x < x1)
                    {
                        if (d < 0)
                        {
                            x++; y++;
                            d += delta2;
                        }
                        else
                        {
                            x++;
                            d += delta1;
                        }
                        bmp.SetPixel(x y Color.Black);//方法2
                        //g.DrawLine(new Pen(Color.Green) xbmp.Height - y  x+1 bmp.Height - y );//方法3
                    }

                }
                else
                {
                    a = y0 - y1;
                    b = x1 - x0;
                    d = a + 2 * b;
                    delta1 = 2 * b;
                    delta2 = 2 * (a + b);
                    x = x0;
                    y = y0;
                    bmp.SetPixel(x y Color.Black); //方法2
                    //g.DrawLine(new Pen(Color.Green) x bmp.Height - y  x+1 bmp.Height - y);//方法3
                    while (y < y1)
                    {
                        if (d > 0)
                        {
                            x++; y++;
                            d += delta2;
                        }
                        else
                        {
                            y++;
                            d += delta1;
                        }
                        bmp.SetPixel(x y Color.Black);//方法2
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-10-28 08:23  活性边表\
     目录           0  2014-11-12 03:11  活性边表\活性边表\
     文件        1005  2014-10-28 08:23  活性边表\活性边表.sln
     文件       39424  2014-11-12 03:11  活性边表\活性边表.v12.suo
     文件         187  2014-10-28 08:23  活性边表\活性边表\App.config
     目录           0  2014-10-28 08:23  活性边表\活性边表\bin\
     目录           0  2014-10-28 08:25  活性边表\活性边表\bin\Debug\
     文件       20992  2014-11-12 03:11  活性边表\活性边表\bin\Debug\活性边表.exe
     文件         187  2014-10-28 08:23  活性边表\活性边表\bin\Debug\活性边表.exe.config
     文件       40448  2014-11-12 03:11  活性边表\活性边表\bin\Debug\活性边表.pdb
     文件       24224  2014-11-12 03:11  活性边表\活性边表\bin\Debug\活性边表.vshost.exe
     文件         187  2014-10-28 08:23  活性边表\活性边表\bin\Debug\活性边表.vshost.exe.config
     文件         490  2013-06-18 20:28  活性边表\活性边表\bin\Debug\活性边表.vshost.exe.manifest
     文件       18389  2014-11-12 03:11  活性边表\活性边表\Form1.cs
     文件       21258  2014-11-12 02:11  活性边表\活性边表\Form1.Designer.cs
     文件        5817  2014-11-12 02:11  活性边表\活性边表\Form1.resx
     目录           0  2014-10-28 08:23  活性边表\活性边表\obj\
     目录           0  2014-11-12 03:11  活性边表\活性边表\obj\Debug\
     文件        1453  2014-11-08 16:11  活性边表\活性边表\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7156  2014-10-28 08:23  活性边表\活性边表\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2014-10-28 08:23  活性边表\活性边表\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2014-10-28 08:23  活性边表\活性边表\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2014-10-28 08:23  活性边表\活性边表\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2014-10-28 08:23  活性边表\活性边表\obj\Debug\TempPE\
     文件        1149  2014-11-12 03:11  活性边表\活性边表\obj\Debug\活性边表.csproj.FileListAbsolute.txt
     文件         977  2014-11-12 02:11  活性边表\活性边表\obj\Debug\活性边表.csproj.GenerateResource.Cache
     文件        2211  2014-10-28 09:36  活性边表\活性边表\obj\Debug\活性边表.csprojResolveAssemblyReference.cache
     文件       20992  2014-11-12 03:11  活性边表\活性边表\obj\Debug\活性边表.exe
     文件         180  2014-11-12 02:11  活性边表\活性边表\obj\Debug\活性边表.Form1.resources
     文件       40448  2014-11-12 03:11  活性边表\活性边表\obj\Debug\活性边表.pdb
     文件         180  2014-10-28 08:25  活性边表\活性边表\obj\Debug\活性边表.Properties.Resources.resources
............此处省略8个文件信息

评论

共有 条评论

相关资源