Image is stretching in iphone? - iphone

I am working on UIImageview image. I downloaded the image above using AsynchronousFreeLoader and assigned it to imageview, but the image is stretching a lot.
I used the contentmode is UIViewContentModeScaleAspectFit. I already tried to set it to UIViewContentModeScaleAspectFill, but it is also stretched.
Image size is 400 x 400 and send it to server.
Can anyone tell me how to show the image in imageview without stretching it?

Related

adjusting images from my api to fill uiimageview of our desired width and height

My application is downloading image files from the api network call, and loading them directly into the tableviewcell uiimageview. Some of those images are smaller and some are bigger in size. I would like to know how to resize an image of any size to our desired uiimageview size in our tableview cell. Please help me with this.
I tried my UIImageview's content modes both "aspectfit" & "aspect-fill" still the images are not sizing to the desired uiimageview size.

Clipping issues when picking from uiimagepicker

I have been dealing with this issues for a few days now trying to figure out why images are clipping whenever I pick from the uiimagepicker. I have this button in my view controller that will take on the image that is chosen from the uiimagepicker. The image shows up but there is this weird clipping affect where it shows the entire image but there is this empty space that is black that makes the image look like it is being clipped.
The image of what the issue I am dealing with is below:
image of the current clipping issues
As now, your image view content mode is .fit that's why this is happening, For now, You need to set imageView content mode scaleAspectFill:
imageView.contentMode = UIViewContentMode.scaleAspectFill
imageView.clipsToBounds = true

does UIViewContentModeScaleAspectFit scale image everytime leaving transparent area around

I am having a hard time understanding how the UIViewContentModeScaleAspectFit works . I am working on app in which i want that the image should be redrawn in such a way that there must be blank area around the image and the image must be set in the center of the image view.
My main concern is that will the UIViewContentModeScaleAspectFit scale image leaving an transparent area around (in every case) or do i need to redraw image programmatically.
If the background of the UIImageView that contains that image is white, then the areas not filled by the image will be white in that view.

How to set the image into fit screen in the image view

I am new to iphone development. I want to display the actual size of the image in image view. I have created image view by using Interface builder and set the properties. Now the problem is, I have set into "Scale to Fill", then the image will be stretched in the full screen. Now i want to display the actual size of the image will be displayed in image view. For example 52X52 size image should be displayed with the same size in the image view.The 1200X1020 size image should be fit to the size of the image view .So according the size of the image it should fit to image view and i want the image smaller than image view should retain its original size(It should not stretch to fit the image view).
Is it any possible solution to achieve it, please guide me.
Thanks.
You're going to have to check the dimensions on the UIImage yourself and then set the proper property on the UIImageView: myImage.contentMode = UIViewContentModeCenter , etc
The different content modes: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/c/econst/UIViewContentModeScaleToFill

iPhone - Center UIImage in UIImageView

I have a UIImageView. I get a UIImage from a URL. The image displays in the UIImageView, but I can't get it to center correctly. The UIImage is 80 x 68 pixels. The UIImaveView's size is 90 x 90. When I display the UIImage in the UIImageView the UIImage is shrunken so that it fits, although it is already smaller than the UIImageView. I have tried all the Content Modes in IB. Some of them shift the image up so that it is no longer in the UIImageView. None of this really makes sense to me. It seems that the UIImage should display inside the UIImageView fine if it is already within the required size. Any help would be great.
With Mode of Center on the UIImageView
alt text http://img406.imageshack.us/img406/3696/screenshot20090915at447.png
With Mode of Aspect Fit on the UIImageView
alt text http://img406.imageshack.us/img406/9373/screenshot20090915at447e.png
With Center, the size of the image seems correct but you can see that it goes out of the UIImageView which has a red UIView underneath it and is actually 2px on each side larger than the image view. But with the Aspect Fit, it makes the image smaller so that it fits inside. But I don't understand why it would make it smaller if it is already small enough to fit.
Sorry for wasting anyone's time. Turns out I didn't try all of the content modes. Seems that Content Mode of Bottom top works. This is backwards from how I understood it. Thanks for all your help.
Try this. Change your UIImageView to be the same size as the UIImage that you are going to load, then position the UIImageView so that it's centered. This is the approach I've taken since I find UIImageView to be a bit funny to work with. Or, if you prefer, skip the UIImageView and just draw the UIImage using it's - (void)drawInRect:(CGRect)rect method.
Sounds like your image contains transparent areas, at least at the bottom, which shift the image off center.
Edit: Also, you should check that the resolution of the image is set to 72dpi.