zoukankan
html css js c++ java
简单的GDI+处理图片大小(C#代码)
/**/
///
<summary>
///
缩放图片
///
</summary>
///
<param name="img">
原图片
</param>
///
<param name="xWith">
缩放宽比例,如果想缩小图片,小于100
</param>
///
<param name="yHeight">
缩放高比例
</param>
///
<returns>
返回处理后图片
</returns>
public
Image scaleImg(System.Drawing.Image img,
int
xWith,
int
yHeight)
{
//
计算处理后图片宽
int
i
=
Convert.ToInt32(img.Width
*
xWith
/
100
);
//
计算处理后图片高
int
j
=
Convert.ToInt32(img.Height
*
yHeight
/
100
);
//
格式化图片
System.Drawing.Image imgScale
=
new
System.Drawing.Bitmap(i, j, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
System.Drawing.Graphics g
=
System.Drawing.Graphics.FromImage(imgScale);
System.Drawing.Rectangle srcRect
=
new
System.Drawing.Rectangle(
0
,
0
, img.Width, img.Height);
System.Drawing.Rectangle desRect
=
new
System.Drawing.Rectangle(
0
,
0
, imgScale.Width, imgScale.Height);
g.Clear(System.Drawing.Color.White);
g.DrawImage(img, desRect, srcRect, System.Drawing.GraphicsUnit.Pixel);
//
处理后的图片另存
imgScale.Save(
"
E:\\1111.jpg
"
, System.Drawing.Imaging.ImageFormat.Gif);
g.Dispose();
return
imgScale;
}
白虎
Hello! I Am David.DU.
查看全文
相关阅读:
aix lvm_lv_vg
Centos6.5 telnet wireshark
Qt开发初步,循序渐进,preRequest for 蓝图逆袭
CentOs文件实时同步
Qt GUI开发实战初期
linux环境开发私房菜
linux GUI程序开发
Centos6.5 Qt4开发 Cannot find -lGL QApplication not file or dir
Centos6.5升级gcc for qt5.3.1
对Socket CAN的理解(5)——【Socket CAN控制器的初始化过程】
原文地址:https://www.cnblogs.com/whitetiger/p/1235341.html
最新文章
Number Sequence
[置顶] Java 8全面解析!不知道的来看看那!
oracle数据库中insert与select
(step 8.2.8)hdu 1079(Calendar Game)
HDU 3468 BFS+二分匹配
windows下安装mysql5.6.13的主从复制
Oracle多表的简单查询
【Unity技巧】使用单例模式Singleton
[REST Jersey] @QueryParam Demo
Bootstrap全局CSS样式之button和图片
热门文章
使用 Unicode 编码
LeetCode --- 59. Spiral Matrix II
2013 成都邀请赛
《ASP.NET》数据绑定—DataList实践篇
关于Memcached的CAS和Set方法造成Socket泄漏的问题
LeetCode——Gas Station
杂七杂八的兼容性測试(一)
call lua function from c and called back to c
赵雅智_Swift(2)_swift常量和变量
Qt
Copyright © 2011-2022 走看看