请viena单独讨论图片缩放问题,非请勿进,多谢 先按最大宽度算出等比压缩高度如果算出的高度不超过最大高度限制,OK否则同理按最大高度算出等比压缩宽度,注意此时所用的源宽高是第一步算出的我好像有点明白你的意思了,我再细想想你再举个例子整明白点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是不是这样,你看还能优化吗?---------------------------------------------------public struct Size{ int Width; int Height;}Size size = new Size();size.Width = 最大宽度;size.Height = 最大高度;if(实际宽度 >= 最大宽度){ //按最大宽度缩放 size.Width = 最大宽度; size.Height = 实际高度 * 最大宽度 / 实际宽度; if(size.Height > 最大高度){ //按最大高度缩放; size.Height = 最大高度; size.Width = 实际宽度 * 最大高度 / 实际高度; return size; } return size;}else{ if( 实际高度 > 最大高度){ //按最大高度缩放; size.Height = 最大高度; size.Width = 实际宽度 * 最大高度 / 实际高度; return size; }}return size; 代码还可以优化,两步是可以分开的size.Width = 实际宽度;size.Height = 实际高度;if(size.Width > 最大宽度){ //按最大宽度缩放 size.Width = 最大宽度; size.Height = size.Height * 最大宽度 / size.Width;}if(size.Height > 最大高度){ //按最大高度缩放; size.Height = 最大高度; size.Width = size.Width * 最大高度 / size.Height;}return size; 第一步得到的结果size,可以在第二步中使用,因为这个size,已经没有宽度问题了只要解决高度问题即可 没必要一定操作原size,因为宽高比例是永远不变的 我是忙里偷闲,在web区灌,俺也得干活了不灌了,有空聊 动态调用WebService 的问题~~ 不知道为什么 textbox验证输入 怎样控制contextMenuStrip在特定区域弹出? 初学者的菜鸟问题,但也是个问题,谢谢解答! 请问高手:如何在安装程序中让用户输入一定的信息并保存起来。 菜鸟关于连接数据库的连接优化初级的疑问.大虾帮帮我. winform 打包部署 打包工具 如datatable中有数据变化 那么数据库相对应的表中数据也更新,怎么写这个代码? 探讨ListBox 如果borland公司推出C#的编辑器就好了 请问:写软件需求文档,有没什么好用的软件?,谢谢! 图片处理问题
---------------------------------------------------
public struct Size{
int Width;
int Height;
}
Size size = new Size();
size.Width = 最大宽度;
size.Height = 最大高度;if(实际宽度 >= 最大宽度){
//按最大宽度缩放
size.Width = 最大宽度;
size.Height = 实际高度 * 最大宽度 / 实际宽度;
if(size.Height > 最大高度){
//按最大高度缩放;
size.Height = 最大高度;
size.Width = 实际宽度 * 最大高度 / 实际高度;
return size;
}
return size;
}
else{
if( 实际高度 > 最大高度){
//按最大高度缩放;
size.Height = 最大高度;
size.Width = 实际宽度 * 最大高度 / 实际高度;
return size;
}
}
return size;
size.Width = 实际宽度;
size.Height = 实际高度;
if(size.Width > 最大宽度){
//按最大宽度缩放
size.Width = 最大宽度;
size.Height = size.Height * 最大宽度 / size.Width;
}
if(size.Height > 最大高度){
//按最大高度缩放;
size.Height = 最大高度;
size.Width = size.Width * 最大高度 / size.Height;
}
return size;
可以在第二步中使用,
因为这个size,已经没有宽度问题了
只要解决高度问题即可
不灌了,有空聊