How to know the image size after applying aspect fit for the image in an UIImageView
Why not use the OS function AVMakeRectWithAspectRatioInsideRect?
Why not use the OS function AVMakeRectWithAspectRatioInsideRect?
Update September 2020 Firefox and edge have implemented the behaviour from the specs and margin + padding for flex elements are both calculated according to the width of the containing block. Just like block elements. Update February 2018 Firefox and edge have agreed to change their behaviour on top, bottom margin and padding for flex … Read more
How to do it nowadays: Since this is one of the most famous questions on libgdx here, I’ll give it a little update: LibGDX v1.0 introduced Viewport to handle this problem. It is a lot easier to use and the scaling strategy is pluggable, which means a single line can change the behaviour and you … Read more
How about: html, body { margin:0; padding:0; overflow:hidden } svg { position:fixed; top:0; bottom:0; left:0; right:0 } Or: html, body { margin:0; padding:0; overflow:hidden } svg { position:fixed; top:0; left:0; height:100%; width:100% } I have an example on my site using (roughly) this technique, albeit with 5% padding all around, and using position:absolute instead of … Read more
Your understanding for the way app:layout_constraintDimensionRatio works is correct. If you set app:layout_constraintDimensionRatio=”H,3:1″ then it means width will be first computed from other constraints and then height will be adjusted according to the aspect ratio. The only problem with your implementation is that you added app:layout_constraintBottom_toBottomOf=”parent” to the ImageView, so that it caused app:layout_constraintDimensionRatio to … Read more
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 the GCD for … Read more
(out of date) Spreadsheet of device metrics. SEE ALSO: Device Metrics – Material Design. Screen Sizes. ————————— —– ———— ————— ——- ———– —————- — ———- Device Inches ResolutionPX Density DPI ResolutionDP AspectRatios SysNavYorN ContentResolutionDP ————————— —– ———— ————— ——- ———– —————- — ———- Galaxy Y 320 x 240 ldpi 0.75 120 427 x 320 4:3 … Read more
I like the above solutions, but they do have the drawback that you need to keep track of the ranges and means over all your data. This could be cumbersome if you have multiple data sets that will be plotted together. To fix this, I made use of the ax.get_[xyz]lim3d() methods and put the whole … Read more
I’m using this method -> based on API Demos to get my Preview Size: private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) { final double ASPECT_TOLERANCE = 0.1; double targetRatio=(double)h / w; if (sizes == null) return null; Camera.Size optimalSize = null; double minDiff = Double.MAX_VALUE; int targetHeight = h; for (Camera.Size size : sizes) … Read more
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*) sourceImage scaledToWidth: (float) i_width { … Read more