正好之前有写过这个,不过是用的.net自带的api写的,如果想要弄的很好的话非常难,有兴趣可以看一下插值法,有若干种办法不一一列举。
///
我觉得你的问题是改变了图片的比例,造成图片失真,我建议你采用等比缩放的方法来缩小比例,而不是简单的在长和宽上各减去100。
可以参考如下方法
public static void GetThumbSize(ref int width,ref int height, int limitWidth,int limitHeight)
{
int scaling = width / height;
if (width > limitWidth)
{
width = limitWidth;
height = width / scaling;
}
if (height > limitHeight)
{
height = limitHeight;
width = height * scaling;
}
}
获得合适的长宽后在做你想要的操作
插值法计算