扭曲图片(验证码)的较正处理C#代码

在很多的验证码图片中,作者会刻意将图片中的文字“扭曲”一下,如下变成斜体。这样就会增加程序识别的难度。作为挂机程序的编写者,自然要反其道而行之,比较有效的一种方法是将“扭曲”的过程反过来校正一下,如图。这样处理,就比较容易分割了。

实现的代码如下:
 1          private   void  button2_Click( object  sender, EventArgs e)
 2          {
 3            Bitmap curBitmap = new Bitmap(pictureBox1.Image.Width,pictureBox1.Image.Height);
 4            Graphics g = Graphics.FromImage(curBitmap);
 5            Matrix X = new Matrix();
 6            //  X.Rotate(30);
 7            X.Shear((float)0.166666666670);   //  2/12
 8            g.Transform = X;
 9            // Draw image
10            //Rectangle cloneRect = GetPicValidByValue(128);  //Get Valid Pic Rectangle
11            Rectangle cloneRect = new Rectangle(654012);
12            Bitmap tmpBmp = ((Bitmap)pictureBox1.Image).Clone(cloneRect, pictureBox1.Image.PixelFormat);
13            g.DrawImage(tmpBmp,
14                new Rectangle(654012),
15                 00, tmpBmp.Width,
16                 tmpBmp.Height,
17                 GraphicsUnit.Pixel);
18            
19            pictureBox2.Image=curBitmap ;
20        }

21

转载于:https://www.cnblogs.com/yuanbao/archive/2007/10/06/915497.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值