aspect-ratio

Qt layouts - Keep widget aspect ratio while resizing [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-07 08:10:57
问题 This question already has answers here : How to maintain widgets aspect ratio in Qt? (4 answers) Closed 5 years ago . I want to keep an aspect ratio of 16/9 on a QGroupBox (the one on the left on the screenshot below). For the tests I made a simple program with 4 groupboxes in a vertical layout, all in an horizontal layout: main.cpp #include "MainWindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }

Keeping aspect ratio when resizing in OpenGL

那年仲夏 提交于 2019-12-07 07:56:54
问题 I implemented the following code: void TestGlPlot::resizeGL(int width, int height) { setupViewport(width, height); } void TestGlPlot::setupViewport(int width, int height) { /* Prevent divide by zero --------------------------------------------------------------------*/ if (height == 0) height = 1; /* Calculate aspect ratio --------------------------------------------------------------------*/ float aspectRatio = (float)width / (float)height; /* Set viewport to cover the window ---------------

Resize JPEG image to fixed width, while keeping aspect ratio as it is

半世苍凉 提交于 2019-12-07 04:26:26
问题 How would you resize a JPEG image, to a fixed width whilst keeping aspect ratio? In a simple way, whilst preserving quality. 回答1: This will scale in the vertical axis only: public static Image ResizeImageFixedWidth(Image imgToResize, int width) { int sourceWidth = imgToResize.Width; int sourceHeight = imgToResize.Height; float nPercent = ((float)width / (float)sourceWidth); int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); Bitmap b = new Bitmap

Android: MediaPlayer video aspect ratio issue

ぃ、小莉子 提交于 2019-12-07 03:46:31
问题 I am having an issue that I am unable to resolve. I am using MediaPlayer class to play video; however, I am always loosing the original aspect ratio. The media player code and the xml code is mentioned here. I have tried so many things but still not able to resolve the issue. I need to maintain the original aspect ratio. I have declared this activity to be full screen in my Android Manifest File. I have also attached the xml code here after the media player code. Please advise me. private

Flexbox, responsive grid of square divs maintaining aspect ratio

喜你入骨 提交于 2019-12-07 01:16:53
问题 I'm trying to create a 2x2 grid with divs. Some of the divs might contain an image, but it will probably be set as a background, with the option background-size: cover . Here's the pen I created: http://codepen.io/qarlo/pen/vLEprq .container { display: flex; flex-wrap: wrap; justify-content: space-between; margin: auto; max-width: 960px; width: 80%; } .container__item { align-content: center; border: 1px solid #333; display: flex; flex-basis: 1; font-size: 3em; justify-content: center; height

Maintain aspect ratio and font size based on browser height and width?

江枫思渺然 提交于 2019-12-06 12:39:27
The code below is attached to window.onresize = resize; . The baseWidth and baseHeight are read on load as a basis for the calculations. The main variable is defined just by setting it to the main html node. The font is set on a block element to cause all of the em based elements within it to resize in kind. When the width or height of the browser is changed then the ratio is recalculated. Please see demo to understand what I achieve with JS but would like to find a pure CSS solution: http://codepen.io/anon/pen/nLauF I have been exploring options in CSS3 such as calc . Feel free to also

Dimensions of usable space in window (action bar and margin excluded)

我怕爱的太早我们不能终老 提交于 2019-12-06 12:11:29
Disclaimer: I rewrote most of this question, including its title, because I partially figured it out. I'd like to maximize the size of the button on all screen sizes, because it looks silly when it is to small. It should look similar to this: (Sadly, I cannot include a picture, because my reputation is too low.) But if I turn the orientation of the device, for example, the button matches it's parents width, becoming ugly proportioned. (Sadly, I cannot include a picture, because my reputation is too low.) I now have figured out how to get the dimensions of its parent (the LinearLayout) and how

How to keep the aspect ratio of a UserControl?

我是研究僧i 提交于 2019-12-06 10:34:28
问题 Does anyone have an idea how to keep the Height/Width Ratio 1:1 of a UserControl? E.g. if Height > Width, Width & Height will have the same size and vice versa. 回答1: I'm not sure this will work, but if you register a handler for the SizeChanged event and in there put in your code keep the aspect ratio 1:1. The SizeChangedEventArgs argument has the old size and the new size so you can check which has changed and update the other accordingly. You might need to introduce a guard variable so that

How to maintain the aspect ratio when using GPUImage?

空扰寡人 提交于 2019-12-06 10:15:26
问题 I found the Instagram has a camera window like 300*300? its a square, then Im trying to use the GPUImage to make the same camera size.so I wrote like this: primaryView = [GPUImageView alloc] initWithFrame: CGRectMake(0,0,300,300)];//define a square view //define a still camera stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionFront]; //make it portrait stillCamera.outputImageOrientation =

Resize UILabel correct on top of UIImageView

廉价感情. 提交于 2019-12-06 10:01:31
问题 My problem is as follows: I have on top of a UIImageView some labels. The image is a formular and the UILabel s represents the entries. If I rotate the device the image inside UIImageView gets resized with option "aspect fit". How can I achieve that the UILabel is also resized and aligned correct? The normal options for resizing aren't working as needed. The UIImageView is zoomable with minimumZoomScale and maximumZoomScale set. Thanks. 回答1: You can resize a UILabel proportionally using: