我为我的网站做的工作很少,我想自动调整我的图像大小。。但不仅可以自动调整大小,还可以保持它们的比例,即使我调整了它们的宽度或高度。我想添加额外的白色边框来补偿新的空间。
我过去从未做过任何图像工作,我应该如何处理这个问题?
我为我的网站做的工作很少,我想自动调整我的图像大小。。但不仅可以自动调整大小,还可以保持它们的比例,即使我调整了它们的宽度或高度。我想添加额外的白色边框来补偿新的空间。
我过去从未做过任何图像工作,我应该如何处理这个问题?
计算高度,假设宽度合适,然后将其与容器的高度进行核对。如果它更高,那么计算宽度以使高度合适:
newHeight = oldHeight * containerWidth / oldWidth;
if (newHeight <= containerHeight) {
newWidth = containerWidth;
} else {
newWidth = oldWidth * containerHeight / oldHeight;
newHeight = containerHeight;
}
现在,您可以计算将图像放置在何处以使其居中:
x = (containerWidth - newWidth) / 2;
y = (containerHeight - newHeight) / 2;
如果你在谈论单源成像,即上传主图像并通过查询字符串请求其版本,那么我可以提供帮助。
我是http://imageresizing.net/一这是一个由附加插件资助的开源库。
您想要的功能包含在免费核心中——只需安装并添加?宽度=100&;height=100到任何图像URL。
用ASP.NET进行图像处理。NET非常棘手。除非你有很强的Win/C++背景,否则你真的不应该这样做。NET不垃圾回收系统。绘图实例。
I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...
I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...
I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?
How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...
I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...
When I m trying to change the default Image of a Control on Windows Forms in Form Designer (no matter where on which control) I get this error: Error message: An item with the same key has ...
I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.