find proportional height of UIImage from fixed width in iphone - iphone

Hello my question is very similar to this question
I am arranging images in a grid manner. this grid has three columns, every column has fixed width of 100px and i want to scale UIImage with this width.
For better explanation i have attached an image
As shown in image i want to find the height.

I suggest you, if possible, use PSCollectionView for this type of display.

Related

Set Constraints of Image using XCode 11

I'm trying to constraint one dog image so that it is centered vertically in the container, which I can do. What I can't seem to get it is having it just above the halfway horizontal point. So I want it to be a certain fraction down the screen (say a third) on any device. I also want the size of the image to be relative to the screen size.
I want the image to be about what it is in the image but maintain its proportions relative to the device of the user.
I've tried tons of things and none of them work. Any help is appreciated.
Here's the Image
Create an UIView and set the image to fill the UIView. After that make the UIView top constrain equal to the centerY anchor which makes the UIView below center horizantal. By using layout anchors for width and height ( not fixed hard coded numbers) you will make it's size relative to device size so doesn't matter using any device type. Post a graphical design if you need more specific answer.

Swift image Aspect Fill for tall image not working

I have this UIImageView which may contain images with different ratios.
I have studied the properties of UIImageView and it seems that the Aspect Fill property set for the Mode of the View should be what I need.
It works as intended when the image is wider than taller: cuts the left and right parts of the image out of the UIImageView.
However if the image is taller than wider it does not cut the above and below part of the image, it allows the image to come out of its view and overlap below views.
These are the constraints I have for the UIImageView:
I have seen several tutorials proceeding like I do, but the result is different for me.
If the image is fitting correctly, but is extending outside the bounds of the image view, try turning on "clip subviews"
For such condition , Two possible solution may help :
Calculate aspect ratio based on your required dimension so that picture quality remains intact . ( ** use Aspect Fit calculator to find required ratio)
CENTER OR ASPECT FIT attributs of Imageview
Thanks

AutoLayout to adjust image size proportional to 50%

I have read this post and I have tried with many examples but i could not put two images one beside the other, each one with a width 50% and at the same time that this images maintain their aspect ratio. I do not understand what restrictions need to.
I have this:
In the image you can see the viewcontroller structure, 2 imageview and the constraints.
Please I need help, at least one similar example. Thanks.
I can see you have missing constraints on your scene, so that could be an issue.
I would put the UIImageViews in a container view pinned to your main view, making sure there are no missing constraints. The benefit of this is in debugging - you can give it a different BG colour and make sure it's resizing itself properly on the simulator/device. I found that putting the image views inside this helps enormously.
Then you need to specify Aspect Ratio constraints on your image views, and also make them equal widths and heights. Add some small constant horizontal spacing between your image views and top/leading/trailing to the container view, and let auto-layout decide the optimal image sizes.
I've included a screenshot of my storyboard:-
This renders like so:-

Whats the image size to keep in list view of size 70x70 in android

I have the listview with each row have an image on left side and text on right side. I have the xml as shown in below.
<ImageView
android:id="#+id/ivMenuListImage"
android:layout_width="70dip"
android:layout_height="70dip"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:paddingLeft="2dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"/>
I have given the Height and Width as 70x70 and the Images are in higher pixels than this. The list view is displaying well. Now i dont want to use hardcode value. So i gave width and height as wrapcontent and resized the images as 70x70. But the images are looking very blured and image quality is very poor. Please help me.
If your image does not have higher resolution you may need to set
android:scaleType="centerInside"
in order not to stretch the image.
Update:
If you wish the row to appear "larger" on higher dpi devices, first you 1) set all your views' layout_height to wrap_content 2)Create png images with fixed width/height pixels for different density drawable folders. For example, in drawable-mdpi all your png images should have fixed height 70 pixel, then all the rows will appear to be 70dp high in mdpi devices. If you create images of height 96 pixel in hdpi folder, then all hdpi devices will look wider with 96dp height.

How to display particular pixels of an image in imageview in iPhone

I am in a situation in which I need to display particular pixels of an Image in an ImageView.
Is there any way to do this in iPhone?Can anybody provide some Example code to do this?Please help me to solve this problem.
There are many ways to display a small subset of your pixels. You can get the raw pixels with this.
Or you can crop a photo. Or you can mask a photo so you are left with just a small bit of your image.
What exactly do you mean by "display particular pixels"?