当前位置: 首页 > news >正文

如何查询网站是谁做的站长之家的作用

如何查询网站是谁做的,站长之家的作用,企业平台网站制作,专业建设包括哪些方面前言 我们在上位机软件开发过程中经常需要裁剪图像,本文就是对c#中常见的裁剪图像方法进行总结。 1、克隆 直接调用Bitmap的Clone函数,然后指定需要裁剪的区域即可裁剪图像,该种方法不会损失精度 public static Bitmap CropImage_Clone(Bi…

前言

我们在上位机软件开发过程中经常需要裁剪图像,本文就是对c#中常见的裁剪图像方法进行总结。

1、克隆

直接调用Bitmap的Clone函数,然后指定需要裁剪的区域即可裁剪图像,该种方法不会损失精度

 public static Bitmap CropImage_Clone(Bitmap origBitmap, Rectangle rectangle, out bool result){result = false;Bitmap croppedBitmap = null;try{croppedBitmap = origBitmap.Clone(rectangle, origBitmap.PixelFormat);result = true;}catch (Exception ex){}return croppedBitmap;}

2、gdi绘图(低质量)

使用gdi绘图的方式,优点是除了将原始图像根据指定区域裁剪外,而且可以在新的图像上绘制直线、矩形等图形,但是可能会丢失精度。

   public static Bitmap CropImage_Gdi_LowerQuality(Bitmap origBitmap, Rectangle rectangle, out bool result){result = false;Bitmap screenShot = new Bitmap(rectangle.Width, rectangle.Height);screenShot.SetResolution(origBitmap.HorizontalResolution, origBitmap.VerticalResolution);try{Graphics graphics = Graphics.FromImage(screenShot);graphics.DrawImage(origBitmap, 0, 0, rectangle, GraphicsUnit.Pixel);//这里的0,0指的是rectangle矩形图像在新图像中的左上角坐标,如果是截图片则就使用0,0result = true;}catch (Exception ex){}return screenShot;}

3、gdi绘图(高质量)

使用gdi绘图的方式有时候会发现绘制的线条出现了锯齿等,这时候可以通过设置SmoothingMode 属性,这里设置为HighQuality来抵抗锯齿的出现,缺点是计算时间会变长,相当于提高了精度损失了效率。

 public static Bitmap CropImage_Gdi_HighQuality(Bitmap origBitmap, Rectangle rectangle, out bool result){result = false;Bitmap screenShot = new Bitmap(rectangle.Width, rectangle.Height);screenShot.SetResolution(origBitmap.HorizontalResolution, origBitmap.VerticalResolution);try{Graphics graphics = Graphics.FromImage(screenShot);graphics.SmoothingMode = SmoothingMode.HighQuality;graphics.DrawImage(origBitmap, 0, 0, rectangle, GraphicsUnit.Pixel);//这里的0,0指的是rectangle矩形图像在新图像中的左上角坐标,如果是截图片则就使用0,0result = true;}catch (Exception ex){}return screenShot;}

调用

下面的代码中原始图像如下:
在这里插入图片描述
裁剪后的图像如下:
在这里插入图片描述

也就是裁剪出一半大小的图像。并且也可以根据打印出来的信息看到三种方法的执行时间都不相同,使用克隆是速度最快的方法。
在这里插入图片描述

Bitmap bitmap = new Bitmap(@"test.jpg");Rectangle cropArea = new Rectangle(0, 0, bitmap.Width / 2, bitmap.Height); // 示例裁剪区域Stopwatch stopwatch = new Stopwatch();stopwatch.Restart();bool result = false;Bitmap cropImage_Clone = CropImage_Clone(bitmap, cropArea, out result);Console.WriteLine(stopwatch.ElapsedMilliseconds);cropImage_Clone.Save("cropImage_Clone.bmp",ImageFormat.Jpeg    );stopwatch.Restart();Bitmap cropImage_Gdi_LowerQuality = CropImage_Gdi_LowerQuality(bitmap, cropArea, out result);Console.WriteLine(stopwatch.ElapsedMilliseconds);cropImage_Gdi_LowerQuality.Save("cropImage_Gdi_LowerQuality.bmp", ImageFormat.Jpeg  );Bitmap cropImage_Gdi_HighQuality = CropImage_Gdi_HighQuality(bitmap, cropArea, out result);Console.WriteLine(stopwatch.ElapsedMilliseconds);cropImage_Gdi_HighQuality.Save("cropImage_Gdi_HighQuality.bmp", ImageFormat.Jpeg);

总结:

1、对于不需要额外绘制图形的场景直接使用克隆方法
2、对于需要绘制图形的场景使用gdi高质量绘图方法。

http://www.ds6.com.cn/news/93302.html

相关文章:

  • 上海 外贸网站网站建站开发
  • 上海自适应网站设计深圳全网推互联科技有限公司
  • wordpress网站搬免费网站推广2023
  • 企业网站创建小结外贸建站推广公司
  • 3d网页游戏大全宁波seo快速优化公司
  • 简单做网站用什么软件化妆品推广软文
  • 贸易网站建设超级搜索引擎
  • 网站做接口排线方法看广告赚钱
  • 国家卫生和计划生育委员会网站seo关键词优化技巧
  • wordpress网站目录营销网站
  • 网站运营与管理的对策建议最好的网站推广软件
  • 网站建设销售前景百度高级搜索功能
  • 阿里云机器怎么做网站网店代运营十大排名
  • 怎么做公司内部网站安徽搜索引擎优化seo
  • 商标可以做网站吗建一个网站大概需要多少钱
  • 自己可以开发一个appseoaoo
  • 如何建设手机网站网站优化网站优化
  • 房屋自建设计哪个网站好推广普通话的宣传语
  • 合肥手机网站建设百度如何推广广告
  • 天津市做网站百度网址大全旧版安装
  • 河南创达建设工程管理有限公司网站百度免费下载安装百度
  • 免费网站建设培训学校网站seo推广公司靠谱吗
  • 青岛个人接网站建设谷歌seo外链平台
  • 企业网站的搭建流程微信公众号怎么开通
  • 苏州市著名网站制作关键词三年级
  • 新疆建设兵团疫情情况最新消息东莞seo建站如何推广
  • 网站开发翻译插件提高工作效率总结心得
  • 西安网站建设开发查派线下引流的八种推广方式
  • 我想在泉州做网站做网站找哪家好
  • 惠安网站建设报价黄页网络的推广软件