aspect-ratio

Maintain aspect ratio according to width and height

☆樱花仙子☆ 提交于 2019-11-26 06:46:02
问题 It is possible to fit and center a square div in the viewport and always maintain it\'s aspect ratio according to width and height ? Requirements : only CSS the size of the square must adapt to the smallest dimension (width or height) of viewport regardless of the orientation (landscape or portrait) of the viewport. the square must be centered horizontaly and verticaly in the viewport Example: 回答1: To maintain the aspect ratio of a div according to width and height in the viewport, you can

Resize UIImage by keeping Aspect ratio and width

醉酒当歌 提交于 2019-11-26 05:49:48
I seen in many posts for resizing the image by keeping aspect ratio. These functions uses the fixed points(Width and Height) for RECT while resizing. But in my project, I need to resize the view based on the Width alone, Height should be taken automatically based on the aspect ratio. anyone help me to achieve this. The method of Srikar works very well, if you know both height and width of your new Size. If you for example know only the width you want to scale to and don't care about the height you first have to calculate the scale factor of the height. +(UIImage*)imageWithImage: (UIImage*)

What's the algorithm to calculate aspect ratio?

ぐ巨炮叔叔 提交于 2019-11-26 04:59:10
问题 I plan to use it with JavaScript to crop an image to fit the entire window. Edit : I\'ll be using a 3rd party component that only accepts the aspect ratio in the format like: 4:3 , 16:9 . 回答1: I gather you're looking for an usable aspect ratio integer:integer solution like 16:9 rather than a float:1 solution like 1.77778:1 . If so, what you need to do is find the greatest common divisor (GCD) and divide both values by that. The GCD is the highest number that evenly divides both numbers. So

How to maintain widgets aspect ratio in Qt?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 04:20:38
问题 How is it possible to maintain widgets aspect ratio in Qt and what about centering the widget? 回答1: You don't have to implement your own layout manager. You can do with inheriting QWidget and reimplementing int QWidget::heightForWidth( int w ) { return w; } to stay square. However, heightForWidth() doesn't work on toplevel windows on X11, since apparently the X11 protocol doesn't support that. As for centering, you can pass Qt::AlignCenter as the third parameter of QBoxLayout::addWidget() or

How to know the image size after applying aspect fit for the image in an UIImageView

℡╲_俬逩灬. 提交于 2019-11-26 03:53:25
问题 I am loading an image to an imageview with mode as \'Aspect Fit\'. I need to know the size to which my image is being scaled to. Please help. 回答1: Please see @Paul-de-Lange's answer instead of this one I couldn't find anything in an easily accessible variable that had this, so here is the brute force way: - (CGSize) aspectScaledImageSizeForImageView:(UIImageView *)iv image:(UIImage *)im { float x,y; float a,b; x = iv.frame.size.width; y = iv.frame.size.height; a = im.size.width; b = im.size

Resize UIImage by keeping Aspect ratio and width

心已入冬 提交于 2019-11-26 03:26:11
问题 I seen in many posts for resizing the image by keeping aspect ratio. These functions uses the fixed points(Width and Height) for RECT while resizing. But in my project, I need to resize the view based on the Width alone, Height should be taken automatically based on the aspect ratio. anyone help me to achieve this. 回答1: The method of Srikar works very well, if you know both height and width of your new Size. If you for example know only the width you want to scale to and don't care about the

Maintain aspect ratio of div but fill screen width and height in CSS?

て烟熏妆下的殇ゞ 提交于 2019-11-26 03:19:20
问题 I have a site to put together that has a fixed aspect ratio of approximately 16:9 landscape, like a video. I want to have it centred and expand to fill the available width, and the available height, but never to grow larger on either side. For example: A tall and thin page would have the content stretching the full width while maintaining a proportional height. A short wide page would have the content stretching the full height, with a proportional width. There are two methods I\'ve been

Android Camera Preview Stretched

大城市里の小女人 提交于 2019-11-26 01:46:05
问题 I\'ve been working on making my custom camera activity on Android, but when rotating the camera, the aspect ratio of the surface view gets messed up. In my oncreate for the activity, I set the framelayout which holds the surface view that displays the camera\'s parameters. //FrameLayout that will hold the camera preview FrameLayout previewHolder = (FrameLayout) findViewById(R.id.camerapreview); //Setting camera\'s preview size to the best preview size Size optimalSize = null; camera =

CSS force image resize and keep aspect ratio

帅比萌擦擦* 提交于 2019-11-25 23:42:37
问题 I am working with images, and I ran across a problem with aspect ratios. <img src=\"big_image.jpg\" width=\"900\" height=\"600\" alt=\"\" /> As you can see, height and width are already specified. I added CSS rule for images: img { max-width:500px; } But for big_image.jpg , I receive width=500 and height=600 . How I can set images to be re-sized, while keeping their aspect ratios. 回答1: img { display: block; max-width:230px; max-height:95px; width: auto; height: auto; } <p>This image is

Grid of responsive squares [closed]

痴心易碎 提交于 2019-11-25 23:00:56
问题 I\'m wondering how I would go about creating a layout with responsive squares . Each square would have vertically and horizontally aligned content. The specific example is displayed below... 回答1: You can make responsive grid of squares with verticaly and horizontaly centered content only with CSS . I will explain how in a step by step process but first here are 2 demos of what you can achieve : Grid of square images Grid of squares with content Now let's see how to make these fancy responsive