iOS loss of image quality - objective-c

This is the case:
I have an image. In the projects browser it looks good.
/but when I 'load' it in one of my controls the edges get rather blurry. And I'm not resizing it or anything. Why is this?
The image, unloaded:
The image when loaded in a control:
As you can see the corners get rather blurry/streched. Why?

It happened to me in the past.
Most of the time the problem is that the dimensions of the image are different from the dimensions of the controller.
Check you controller size with:
NSLog(#"controller size = %#",NSStringFromRect(your_controller.rect));
And see if it the image size fits.

I've also had this before and as #shannoga said if the dimensions of the view are different to the image it will auto stretch it.
Are you loading the image into an ImageView? if so the imageView.Mode property defaults to Scale To Fill. If you set the mode to Top, Left or Center it wont stretch the image.

Related

Appcelerator Studio - Don't stretch Image

I have a 405x720 image that it is to cover the background image. I've noticed that it stretches the image if the device's screen is smaller than the image. (I'm using a Galaxy S4 to test my apps).
Here's what I have so far:
var fullView = Ti.UI.createImageView({
layout: 'vertical',
width: '100%',
height: '100%',
image: '/images/background.png'
});
I've heard about the clipping technique, however that is only available for iOS and I'd like to have it for both platforms. Is there a way to do this? Or should I try to resize it appropriately? Tips/Suggestions are appreciated!
You should use proper images according to the aspect ratio of screen you are going to run your app on.
You can do this by calculating the width-height ratio of device and then you can decide which image to show on.
But putting a single resolution image directly to cover up the whole screen
is never going to work.
To resize an image, you can use Ti.Blob class' methods after fetching your image using Ti.Filesystem
Also remember that putting an image on whole background takes lot of memory especially in Android. That's why most of the apps do not use complete image to cover up background, rather they use small images wherever necessary and fills up other areas by colors or gradients as required.
But if your requirement is only to use image in background then unload it as soon as you move to different screen and load it again as you are back on it.
Further points to keep note of:
If you set bg image on a View, then it will be fit to cover the dimension of a View. So, if you have a view of width/height to 100%, then image will be fit into it. It means that image size will depend on View's dimension, not the View dimension will depend on image size.
If you set image on ImageView, and suppose you have:
ImageView width = FILL to screen size of 720, then the image height will be automatically decided to keep the aspect ratio. It means that if you have an image of size width=720 and height=400, then the ImageView will be of width=FILL & height=400
Image of size width=1000 and height=800 & ImageView height = 400, then the ImageView will be of width=500 & height=400
The problem is that you're actually telling the image control to load the image on an object that is stretched to the entire width and height of the screen - and when the screen aspect ratio is different than the one you have cropped your image by then you get bad aspect ratio and image looks screwed up.
If you remove either the width or the height, than the aspect ratio of the image will be loaded.
When I want a background image what I found the best way is to make a square image, and then set my ImageView height to Ti.UI.FILL and my width to Ti.UI.SIZE - That way it shows good aspect ratio and side that dont "fit" the screen (width or height) are not shown.

Apply Image in Buttons

As A Begineer I've made a Puzzle game and it's working fine in Iphone Simulators.
But problem occurred when I run it in bigger Screen like IPad Air 2.All the picture aren't fitting perfectly in the buttons
(Note that Images are applied on buttons not in the Background of
buttons)
As image size not fit to given size of button, may be due to size concern of aspect fit property of imageview of button. You can try to scale image proportionally to size of imageview of button and get desire result.
You can refer to this link for scale image as proportionally to desired size.
scale Image in an UIButton to AspectFit?

Resize height of picture and extend width

i have some picture which is 675x503. I would like to make more width on it and let's say to 1024 and in height to 400. How to do that without cutting my image and keep quality? I just would like to have this image on my website top. I got photoshop 6. I tried with Image->image size but its not what i need.
If you don't want to cut the picture at all, this will distort the image due to different height and width ratios. If this is not an issue, you could simply hit ctrl(or cmd)+t when the layer with the picture is selected. It will let you resize and rotate the entire image. There is also an option in the Image -> Image Size menu called "Bicubic Sharper", found in the drop-down list at the bottom of the menu(Photoshop CS6). It's meant for image reduction and should also solve your problem.

NSImageView won't scale image down if frame style is NSImageFrameNone

I need to display NSImageView on resizable NSWindow. The image displayed in the view should scale down if it's too big to fit image view in the widnow and it should also change its size when resizing the window. I am able to achieve correct behavior using Auto-Layout, and setting imageScaling property of NSImageView to NSImageScaleProportionallyDown. Unfortunately it's not working when my image view's imageFrameStyle property is set to NSImageFrameNone (it works for any other option like NSImageFramePhoto or NSImageFrameGrayBezel). I don't want any frame to be displayed, like with NSImageFrameNone, but disabling the frame breaks autoresizing - it looks like with frame set to NSImageFrameNone image is not scaled down and NSImageView is scaled up to match displayed image size. Anyone have solution for that issue?
It occurs that it's easier than I thought. The problem was with Auto-Layout, not with NSImageView scaling logic. Using InterfaceBuilder with my image view selected I had to change "Content Compression Resistance Priority" to lower value (it's located on Size Inspector tab in Xcode5). That solved my problem and the image is now scaled properly when resizing window.

Can a UIViewImage draw its image outside its frame?

When making a photo viewer app found that our UIImageView controller is drawing its image outside its frame when the content mode is different neither ScaleToFill nor Aspect Fit.
Trying to understand why; I isolated the problem making a new project which only has a UIImageView with the following frame (50,50,100,100). The image size contained in it is (4592,3056).
After running the app, with the content mode set to ScaleToFill and AspectFit it all worked as expected:
But after setting the contentMode of the UIImageView to TopLeft, the image is drawn outside its frame, the odd thing is that the log from the frame after all has been drawn is still the original {50,50,100,100}.
I've try to understand the issue by moving the Autoresize, the clips and the content mode of the UIViewController but the result is the same.
set clipToBounds = YES on the view.
its NO by default because that makes drawing way cheaper