如何与QUOT;智能大小调整和QUOT;所显示的图像原始宽高比图像、原始、大小、智能

2023-09-11 03:13:46 作者:鱼的第八秒是重生

我有一个应用程序中,最终用户可以大小和位置图像设计师。因为该规范要求的图像被延伸到包含控制,最终用户可以结束了一个笨拙拉伸图像。

I have an application in which end-users can size and position images in a designer. Since the spec calls for the image to be "stretched" to the containing control, the end user can end up with an awkwardly stretched image.

要帮助图像的用户上浆我想实现一个智能大小调整功能,这样可以让用户轻松地修复图像的长宽比,使其不再显得捉襟见肘了。

To help the user with image sizing I am thinking of implementing a smart resizer function which would allow the the user to easily fix the aspect ratio of the picture so that it no longer appears stretched.

快速的方法来解决,这是实际提供两种选择:1)从高度宽度2)标刻度。用户选择的方法和算法,通过使用原始的宽高比调整图像的大小。例如:一张图片显示为200×200的设计师,但原始图像为1024x768像素。用户选择从宽度智能大小和新的大小变为〜200x150,因为原来的高宽比为1.333〜

The quick way to solve this is to actually provide two options: 1) scale from width 2) scale from height. The user chooses the method and the algorithm adjusts the size of the picture by using the original aspect ratio. For example: A picture is displayed as 200x200 on the designer but the original image is 1024x768 pixels. The user chooses "Smart Size from width" and the new size becomes ~200x150 since the original aspect ratio is ~1.333

这是确定的,但我怎么可能使算法更聪明,而不是问哪个维度重新计算应根据打扰用户?

That's OK, but how could I make the algorithm smarter and not bother the user by asking which dimension the recalculation should be based on?

推荐答案

如果我是跨$ P $正确pting你的天赋,你要的结果是不超过一个最终用户奠定了最初较大;要两个维度收缩之一,而另一个保持不变。

If I'm interpreting your spec correctly, you want a result that is no larger than the one the end-user laid out originally; you want one of the two dimensions to shrink, and the other to stay the same.

original_ratio = original_width / original_height
designer_ratio = designer_width / designer_height
if original_ratio > designer_ratio
    designer_height = designer_width / original_ratio
else
    designer_width = designer_height * original_ratio
 
精彩推荐
图片推荐