UIView manipulation for collage like picture in high resolution - ios

I'm currently working on a collage application where users can combine multiple images into one collage (in a grid like layout, like 2x2). I worked on a couple of examples where coders used a UIView to which the images were added as Subviews. The subviews itself are zoomable and scrollable, so that the images can be adjustet inside their boxes.
The results are then exported as a JPEG reprensentation. While the results are okish, the problem is that output from the UIView only is as big as its screen size (640x640 for a 2x Screen on an iPhone 4 / 5). I was wondering if there would be better way to maybe compose a higher resolution image from the original image sources with consideration of the changes made in the view.
The View

Related

How do working with regular images and images for buttons differ in `ios`?

I'm struggling with understanding how images and their different sizes/resolutions work in ios development.
Do images that will be used for buttons always have to be squares (like App Icons)? and are there specific dimensions that they would need to have?
Also generally speaking, how should images that would be used for buttons be sized in the Assets.xcassets folder as compared to Images that would be shown as regular images? (that is if there is a difference)?
Since you can create buttons of any size you like there is no difference. Your image should match the aspect ratio of the button but it's all entirely up to you.
Sizing in the Assets catalog would be the same as any other image with 1x, 2x and 3x variations.
Try it out in Storyboard and you will see immediate results.

how to load image from camera for specific/variable sizes?

I have a very simple requirement here but I'm looking for a solution for a while. I want to take a profile picture form the camera roll or camera and display it in two different image views (different sizes). I don't want any of these images stretched or miss any part of the image. If I use aspect to fit, top side of image is cut from smaller image view and some parts missing on the bigger image view. If I set it as scale to fit, it will get stretched!
I'm not sure how some mobile apps work. Do they save different image sizes in their server or they change the size of the image. I saw many posts how to change image size without changing aspect ratio. But I don't think it is possible to avoid stretched effects. I used some of those code to change size of image, it gets stretched all the time.
Is there any way to save the image from camera roll one time with size of 140*200 and one time 160*200? So I can use 140*200 for image views that size. But what if I have different devices and different sizes.

supplying the right image size when not knowing what the size will be at runtime

I am displaying a grid of images (3rows x 3 columns) in collection view. Each image is a square and its width is determined to be 1/3 of collectionView's width. Collection view is pinned to left and right margin of the mainView.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+. I was advised to supply images that exactly matches the size on screen. Bigger images often tend to become pixelate and too sharp when downsized. How does one tackle such problem?
The usual solution is to supply three versions, for single-, double-, and triple-resolution screens, and downsize in real time by redrawing with drawInRect into a graphics context when the image is first needed.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+
Okay, so your first sentence is a lie. The second sentence proves that you do know what the size is to be on the different screen sizes. Clearly, if I tell you the name of a device, you can tell me what you think the image size should be. So, if you don't want to downscale a larger image at runtime because you don't like the resulting quality, simply supply actual images at the correct size and resolution for every device, and use the correct image on the actual device type you find yourself running on.
If your images are photos or raster type images created using a raster drawing tool, then somewhere you will have to scale the original to the sizes you want. You can either do this while running in iOS, or create sets up front using a tool which can give you better scaling results. Unfortunately, the only perfect image will be the original with everything else being a distortion of the truth.
For icons, the only accurate rendering solution is to use vector graphics. Tools like Adobe Illustrator will let you create images which you can scale to different sizes without losing clarity. Unfortunately this still leaves you generating images up front. You can script this generation using most tools and given you said your images were all square, then the total number needed is not huge. At most you need 3 for iPhone (4/5 are same width, 6 and 6+) and 2 for iPad (#1 for mini/ipad1 and #2 for retina).
Although iOS has no direct support I know of for vector image rendering, there are some 3rd party tools. http://www.paintcodeapp.com/ is an example which seems to let you import vector images or draw vector images and then generate image code to run in your app. This kind of tool would give you what you want as the images are now vector drawings drawn at the scale you choose at run time. $99 though.
There is also the SVGKit (https://github.com/SVGKit/SVGKit), but not sure how good/bad this is. It seems to let you simply load and render direct from SVG files. Might be worth trying.
So in summary, I think you either generate the relatively small subset up front using a tool you can control the output from, take the hit in iOS and let it scale the images or use a 3rd party vector to image rendering kit which would give you what you want.

iOS, size of images for background

I'm making my first iphone game using swift/xcode with gimp to draw the graphics. I'm having trouble understanding what size I should make the image in gimp to use it for the background of my iphone game.
The various devices have different screen sizes, so presumably you will want your image to adapt. Thus it really isn't about your image but about the image view that will display it (assuming you're using an image view). The things to think about are:
How to use constraints to pin the edges of the UIImageView to the edges of the screen.
How to set the content mode of the UIImageView so that it displays the image acceptably on all device sizes.

UIViewcontroller image dimensions

I wanted to display a png image in the center of my main view controller. Do I have to use a UIImageView or just add the image to the view itself?. I don't want to cover the whole view but just in the center with a fairly large image. What would be the ideal dimensions of the image be for all iOS devices (supporting iOS 6.0 and above)?.
The easiest way is to use UIImageView like you said. There are ways of manipulating other classes to display images, but it's more code overall and more confusing to look at. As for the ideal dimensions, it depends on the aspect ratio of your image and the rest of your view.

Resources