aspect-ratio

Handling different screen resolutions for background images in Android

夙愿已清 提交于 2019-11-30 19:34:20
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 if the player switches between portrait and landscape mode. And to make matters worse, many devices have

Scaling HTML5 canvas width preserving w/h aspect ratio

醉酒当歌 提交于 2019-11-30 19:28:32
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? Trinh Hoang Nhu 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').width() / 2.031); }); 2.031 = 979/482 But you should not attach to $(window).resize like me...

Aspect Ratio Stretching in OpenGL

自古美人都是妖i 提交于 2019-11-30 16:14:39
I am having some trouble with full screen mode. I can set my window to be 800x600, but when I full screen that resolution, it stretches. I assume this is because of a change in aspect ratio. How can I fix this? Edit #1 Here's a screen shot of what I see happening. Left: 800x600 Right: 1366x768 Edit #2 My initGraphics function gets called every time I re-size the window (WM_SIZE). void initGraphics(int width, int height) { float aspect = (float)width / (float)height; glViewport(0, 0, width, height); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); //Enable alpha blending glBlendFunc(GL_SRC_ALPHA,

QPixmap maintain aspect ratio

心已入冬 提交于 2019-11-30 16:10:23
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()) print tempName self.myLabel.setPixmap(QtGui.QPixmap(_fromUtf8(directory + '\\' + tempName))) ##

Get aspect ratio from width and height of image (PHP or JS)

╄→гoц情女王★ 提交于 2019-11-30 14:17:59
问题 I can't believe I can't find the formula for this. I am using a PHP script called SLIR to resize images. The script asks to specify an aspect ratio for cropping. I'd like to get the aspect ratio based on the width and height of the image being specified in a form I'm letting users enter these values in. For example, if a user enters a 1024x768 image, I would get an aspect ratio of 4:3. For the life of me, I can't find an example of the formula in PHP or Javascript I can use to get the aspect

Get aspect ratio from width and height of image (PHP or JS)

一个人想着一个人 提交于 2019-11-30 10:09:17
I can't believe I can't find the formula for this. I am using a PHP script called SLIR to resize images. The script asks to specify an aspect ratio for cropping. I'd like to get the aspect ratio based on the width and height of the image being specified in a form I'm letting users enter these values in. For example, if a user enters a 1024x768 image, I would get an aspect ratio of 4:3. For the life of me, I can't find an example of the formula in PHP or Javascript I can use to get the aspect ratio values based on knowing the w,h and plug the aspect ratio into a variable. There is no need for

Aspect ratio in UIImageView

陌路散爱 提交于 2019-11-30 08:36:35
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? Srikar Appalaraju Doing myImageView.contentMode = UIViewContentModeScaleAspectFit; is one option. But it isn't enough because it changes the aspect ratio of the image, but it doesn't change the

How can I scale video in ExoPlayer-V2 - Play Video In Full Screen

假如想象 提交于 2019-11-30 07:34:08
I am playing video from URL on Exoplayer , it stretching the video on resizing/on using resize_mode as I have mentioned in layout file using this I am not able to maintain the aspect ratio of video. I want to do scale type CENTER_CROP like we do in TextureSurface as mentioned in image2 but I am getting output as image1 I have tried following example Exoplayer Demo Example My Output (Img 1) and Expected Output (Img 2) exoplayer layout code <com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/player_view" android:layout_width="match_parent" android:layout_height="match_parent"

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

醉酒当歌 提交于 2019-11-30 07:17:33
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. But I wonder if I can do better... Perhaps I should intercept the autorotation before it happens (using

How to have a circular, center-cropped imageView, without creating a new bitmap?

佐手、 提交于 2019-11-30 06:53:29
Note : I know there are a lot of questions and repositories about this, but none seems to fit what I try to achieve. Background Given a bitmap of any aspect-ratio, I wish to set it as the content of an ImageView (using a drawable only, without extending the ImageView), so that the content will be center-cropped, and yet in the shape of a circle. All of this, with minimal memory usage, because the images could be quite large sometimes. I do not want to create a whole new Bitmap just for this. The content is already there... The problem All solutions I've found lack one of the things I've