aspect-ratio

ImageAreaSelect: preselect biggest thumbnail possible respecting aspectRatio

非 Y 不嫁゛ 提交于 2019-12-06 08:56:23
This is how I first tried: $('#thumbnail').imgAreaSelect({ x1: 5, y1: 5, x2: $('#thumbnail').width(), y2: $('#thumbnail').width()*0.66, aspectRatio: '1:0.66' }); But some of the cropped image stay off the overflow... This seems to make a preselection for most of the image resolutions I tried... var thwidth = $('#thumbnail').width(); var thheight = $('#thumbnail').height(); aspectRatio = 0.66; $('#thumbnail').imgAreaSelect({ x1: 5, y1: 5, x2: thwidth - 80, y2: (thwidth - 80) * aspectRatio, aspectRatio: '1:0.66' }); But it won't select the maximum possible; plus it looks a bit dirty to me... How

Resizing N # of squares to be as big as possible while still fitting into box of X by Y dimensions. (Thumbnails!)

[亡魂溺海] 提交于 2019-12-06 03:56:17
问题 I have N squares. I have a Rectangular box. I want all the squares to fit in the box. I want the squares to be as large as possible. How do I calculate the largest size for the squares such that they all fit in the box? This is for thumbnails in a thumbnail gallery. int function thumbnailSize( iItems, // The number of items to fit. iWidth, // The width of the container. iHeight, // The height of the container. iMin // The smallest an item can be. ) { // if there are no items we don't care how

Stretch html5 video without keeping aspect ratio in jQuery

天大地大妈咪最大 提交于 2019-12-06 03:32:07
HTML5 videos have intrinsic aspect ratios and tend to keep it, no matter what your CSS tells them to do. I have a responsive video container that isn't 16:9, and I'd like the videos inside it to stretch to 100% width and 100% height, even if it breaks their original aspect ratio. I've read about the CSS object-fit: fill property, which would solve my problem, but there's still a long way to go before modern browsers support it. So I guess I must turn to JavaScript to achieve what I need. I came across this fiddle: http://jsfiddle.net/MxxAv/ function scaleToFill(videoTag) { var $video = $

How to show the same part of game on every aspect ratio on Android devices with Unity?

半腔热情 提交于 2019-12-06 03:04:33
问题 I'm coming from Libgdx engine to Unity and I'm a beginner programmer. I try to make a game in Unity for Android and iOS devices, but I have a problem with the aspect ratio/resolution scaling. In Libgdx if you have develop something you give a "default" resolution, and everything will be scaled to the device's screen, not matter if it has bigger or smaller resolution, and nothing will be cut off from the screen. On the other side, in Unity if I make a game it will crop the screen to the chosen

Image size calculation by keeping aspect ratio with different screen resolutions

半世苍凉 提交于 2019-12-06 02:41:30
问题 I am trying to resize an image by keeping the aspect ratio. It should be just large enough to fill the screen with no blank space and if necessary some of the image should be off-screen. The image below shows how the yellow image should be sized based on the black screen size. Heres the Code that I am actually using, is there any better way to do this? if(bwidth > bheight) { if(bwidth > swidth && bheight > sheight) { new_height = sheight; new_width = (int) ((double) (bwidth/100)*(sheight/(

Resize a Div Based on Height but Retain Aspect Ratio (almost got it) Strange Reload bug

痞子三分冷 提交于 2019-12-05 23:25:23
问题 There are lots of solutions for maintaining aspect ratio when resizing videos based on the width of the parent div. Most of them depend on the fact that "padding-top" and "padding-bottom" are calculated based on width rather than height. I'm trying to do something similar, but I want to resize my video based on the height of the parent div. To do this I need to create a div that keeps an aspect ratio regardless of height. This may be sort of a lame way to do it, but I decided to use an image

Keeping aspect ratio when resizing in OpenGL

瘦欲@ 提交于 2019-12-05 17:59:00
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 ----------------------------------------------------------*/ glViewport(0, 0, width, height); /* Set aspect ratio ----

Detect aspect ratio - HTML5 video

旧巷老猫 提交于 2019-12-05 15:16:32
Is it possible to detect the aspect ratio of an HTML5 video element? I know the video will just shrink to fit in the <video> element's dimensions, but I want to detect the aspect ratio of the source video. That way you could remove any black bars. Sorry I don't see this answered anywhere else. Sebastian Job Bjørnager Jensen Pasting from another StackOverflow answer: https://stackoverflow.com/a/4129189/1353189 <video id="foo" src="foo.mp4"></video> var vid = document.getElementById("foo"); vid.videoHeight; // returns the intrinsic height of the video vid.videoWidth; // returns the intrinsic

Nexus 4 Camera preview aspect Ratio always requires 16x9 surfaceview? Why

杀马特。学长 韩版系。学妹 提交于 2019-12-05 13:39:22
问题 Device Nexus 4 Android ver: 4.2.2 Hoping someone else has found this and can explain how to resolve it.... Nexus 4 supports the following preview sizes: - W:1280 H:720 Ratio: 1.777777 W:800 H:480 Ratio: 1.6666666 W:768 H:432 Ratio: 1.7777778 W:720 H:480 Ratio: 1.5 W:640 H:480 Ratio: 1.3333334 W:576 H:432 Ratio: 1.3333334 W:480 H:320 Ratio: 1.5 W:384 H:288 Ratio: 1.3333334 W:352 H:288 Ratio: 1.2222222 W:320 H:240 Ratio: 1.3333334 W:240 H:160 Ratio: 1.5 W:176 H:144 Ratio: 1.2222222 myCamera

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

谁都会走 提交于 2019-12-05 13:24:16
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(); } MainWindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow;