예제 #1
0
 private void 图片框_MouseDown(object sender, MouseEventArgs e)
 {
     标按下 = true;
     if (e.Button == MouseButtons.Right)
     {
         右键按下 = true;
     }
     坐标 = 图片框.PointToClient(Cursor.Position);
     if (e.Button == MouseButtons.Left && Ctrl按下)
     {
         if (坐标数组 == null)
         {
             坐标数组 = new int[原图.Width * 原图.Height, 2];
         }
         if (原图副本 == null)
         {
             原图副本 = new Bitmap(原图.Width, 原图.Height, 原图.PixelFormat);
         }
         if (HSI位图 == null)
         {
             HSI位图 = 图像.生成HSI位图32(原图);
         }
         try {
             图像.原图刷新图32(原图, 原图副本);
             范围 = new 颜色范围();
             ThreadStart 变透明色  = new ThreadStart(变透明);
             Thread      变透明线程 = new Thread(变透明色);
             变透明线程.Start();
         }
         catch (Exception) {
         }
     }
     if (!Ctrl按下 && e.Button == MouseButtons.Left)  //单击清空虚线框
     {
         图片框.Refresh();
         中区域 = Rectangle.Empty;
     }
     if (右键按下)
     {
         DrawStart(new Point(e.X, e.Y));
     }
 }
예제 #2
0
        public static void 着透明色32(int[,] 坐标数组, int x, int y, Bitmap 位图, Bitmap HSI位图, 颜色范围 范围)
        {
            byte       H, S, I;
            Rectangle  图框    = new Rectangle(0, 0, 位图.Width, 位图.Height);
            BitmapData 位图数据  = 位图.LockBits(图框, ImageLockMode.ReadWrite, 位图.PixelFormat);
            BitmapData HSI数据 = HSI位图.LockBits(图框, ImageLockMode.ReadWrite, HSI位图.PixelFormat);

            unsafe {
                byte *位图指针  = (byte *)(位图数据.Scan0);
                byte *HSI指针 = (byte *)(HSI数据.Scan0);
                I = HSI指针[y * HSI数据.Stride + x * 4 + 蓝];
                S = HSI指针[y * HSI数据.Stride + x * 4 + 绿];
                H = HSI指针[y * HSI数据.Stride + x * 4 + 红];

                for (int 列 = 0; 列 < 位图数据.Height; 列++)
                {
                    for (int 行 = 0; 行 < 位图数据.Width; 行++, 位图指针 += 4, HSI指针 += 4)
                    {
                        if (位图指针[透] == 0)
                        {
                            continue;
                        }
                        if (范围.颜色相似(H, S, I, HSI指针[红], HSI指针[绿], HSI指针[蓝]))
                        {
                            位图指针[透] = 0;
                        }
                    }
                }
            }
            位图.UnlockBits(位图数据);
            HSI位图.UnlockBits(HSI数据);
        }