aspect-ratio

Scaling HTML5 canvas width preserving w/h aspect ratio

感情迁移 提交于 2019-11-30 03:51:38
问题 I have a canvas element with dimensions of 979X482px and I'd like to have it stretch to fit the width of any given browser window, keeping the aspect ratio of width/hight 1 to 1, I want the height to scale relative to width of the canvas. Any suggestions as how to go about doing this with javascript/jQuery? 回答1: First you set the width of canvas to 100% $('#canvas').css('width', '100%'); then update its height base on its width $(window).resize(function(){ $('#canvas').height($('#canvas')

Handling different screen resolutions for background images in Android

对着背影说爱祢 提交于 2019-11-30 03:38:42
问题 My Android app (a text-based game) uses background images a lot in order to provide a better visual ambiance. For example, if the action in the game takes you into a tavern, then you get a background image of a tavern in the game. This is a vast improvement, graphically, over the boring black background that you would otherwise get. It is also a problem, however, since android:background always stretches to the dimensions of the screen. The result is that the background images look very bad

QPixmap maintain aspect ratio

♀尐吖头ヾ 提交于 2019-11-29 23:30:27
问题 I'm writing a program that will allow me to upload photos to TUMBLR via their API, I've got the uploading working (thanks to you guys). I've put a 'queueBox' on the side of the GUI, which displays the image names, and they are stored in a QListWidget. I've put this in my Main Class' constructor: def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.queueBox.itemClicked.connect(self.displayPhoto) and I have this method: def displayPhoto(self, item): tempName = (item.text

Algorithm to resize image and maintain aspect ratio to fit iPhone

怎甘沉沦 提交于 2019-11-29 23:19:20
I'm creating a web service for an iPhone app to interact with. When my client uploads images server-side, I want my php script to resize the image, whilst maintaining the aspect ratio , so that it will fit onto the iPhone screen. (i.e. the longest side is <= 960 and the shortest <= 640 I've created a mock-up in JS, simply because I find it easier to do quickly. I'm pretty sure, though I may be wrong, that this isn't the most efficient way of doing it. Could someone correct me with either better logic (especially the bit at the start), or a more mathematical way of approaching this? var w = 960

Multiple screen resolutions/aspect ratios (games)

笑着哭i 提交于 2019-11-29 20:15:21
EDIT: Thanks for all your answers and comments. After thinking about it i would rephrase the core of the question to: "How to determine and limit the minimum resolution/ratio my game is able to run on". Because imo either the game becomes unplayable on the smallest screen/ratio (lack of detail) or supporting even the smallest screen/ratio degrades the experience for all the others significantly. Besides we do not even know what the smallest resolution is or can restrict it in any way other than disabling ldpi... which still doesn't tell us about the smallest mdpi. After all i'm not thinking

WPF Resize UserControl with aspect ratio

跟風遠走 提交于 2019-11-29 16:08:46
I have a UserControl and that UserControl has to be resized with aspect ratio. That means: width:height = 2:1. Currently I am using this code: protected override Size ArrangeOverride(Size arrangeBounds) { if (ActualWidth == 0 || ActualHeight == 0) return arrangeBounds; base.ArrangeOverride(arrangeBounds); double ratio = 2; if (Parent != null) { var size = new Size(arrangeBounds.Height * ratio, arrangeBounds.Height); double containerWidth = ((FrameworkElement)Parent).ActualWidth; if (containerWidth < size.Width) { double newHeight = arrangeBounds.Height * (containerWidth / size.Width); canvas

Aspect ratio in UIImageView

£可爱£侵袭症+ 提交于 2019-11-29 12:03:06
问题 I got app which can add photo from camera or gallery. After adding each photo showes in UIImageView . But they show with bad aspect ratio. Photoes are extended on UIImageView's size. How can i show photoes with their real aspect ration? UPD and what about small pictures? if user will add really small picture, this picture will resize on all area of UIImageView . How show this pictures in real size? 回答1: Doing myImageView.contentMode = UIViewContentModeScaleAspectFit; is one option. But it isn

Field of view + Aspect Ratio + View Matrix from Projection Matrix (HMD OST Calibration)

一曲冷凌霜 提交于 2019-11-29 11:54:06
I'm currently working on an Augmented reality application. The targetted device being an Optical See-though HMD I need to calibrate its display to achieve a correct registration of virtual objects. I used that implementation of SPAAM for android to do it and the result are precise enough for my purpose. My problem is, calibration application give in output a 4x4 projection matrix I could have directly use with OpenGL for exemple. But, the Augmented Reality framework I use only accept optical calibration parameters under the format Field of View some parameter + Aspect Ratio some parameter +

How to avoid momentary stretching on autorotation of iOS OpenGL ES apps

吃可爱长大的小学妹 提交于 2019-11-29 09:16:07
问题 This has been bugging me recently. It is quite straightforward to put together an OpenGL ES app that supports both portrait and landscape. But during autorotation, the system seems to just forcibly stretch the render buffer to the new dimensions once, autorotate, and then call the usual -layoutSubviews -> -resizeFromLayer: etc. so the drawables can be adjusted to the new viewport dimensions. Most apps I've seen that support both portrait and landscape seem to settle for this easy approach.

Android VideoView crop_center

本秂侑毒 提交于 2019-11-29 04:08:21
I have a RelativeLayout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:foregroundGravity="center" android:gravity="center" android:orientation="horizontal" > <VideoView android:id="@+id/videoViewPanel" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:layout_centerInParent="true"/> </RelativeLayout> And what I need is to show video fullscreen cropped. If I could compare to ImageView, I need to