How can I consume a graphic and then generate objective-c code that can draw it? The code generation doesn't need to be written in objective-c, but must generate objective-c code.
Input: A.png
Output: Core Graphics code to generate a file A.png that would match the image of the original file, A.png.
For example, since I can find out the color and position of every pixel, what tool can I use to write iOS code that draws those pixels exactly.
Why inflate the bundle size with images or why wait to pull down images from a web service when the app itself could generate those images with the right instructions.
My intention is to use this in a white label solution.
Why inflate the bundle size with images or why wait to pull down images from a web service when the app itself could generate those images with the right instructions
Because your code will still need to contain all the information contained in the image, plus all those drawing instructions, so you're going to end up with a larger product, not a smaller one. Additionally, building the image data into the code makes it that much harder to change.
Use PaintCode to create your graphics.
You are done.
Related
I am working on implementing a zoomable image viewer using OpenSeadragon and deep zoom images. I used the VIPS command line tool to create DZI files. My question is, does the original image used to create DZI files need to meet specific requirements to make it zoomable? (like format, size, etc.) If a normal .jpg image is converted to DZI, it seems like the image will not be zoomable. Is this correct?
My question is, does the original image used to create DZI files need to meet specific requirements to make it zoomable?
No, except to have a resolution higher than the screen resolution (in that case, the original image can be displayed directly).
Icons Are Pretty Right?
I'm working on an UI update in an iOS app, and trying to make things look a bit better with some new icons- but I seem to be incapable of determining how to save an image correctly so that it looks good in the interface!
As you can see from this image, if I include a white background with the image it looks great. If I take those same images and use an alpha background they look terrible! It appears that either the images aren't using the #2x correctly, or something else is going horribly wrong.
These images are either saved with GIMP as a png with alpha, or exported from inkscape, the originals are vector graphics. We get the same results from both avenues. I am using both a base imageName.png and imageName#2x.png for scaling.
Somehow, magically, I changed the a single image to greyscale in gimp, and changed the base size to 25px and it showed up with alpha correctly blended. Stock images from apple are also functioning correctly, so it absolutely seems to be something that I'm doing incorrectly when I'm saving the images.
The Setup in XCode
Basic Questions
Is there a certain bit depth, argb vs rgba format, or some other quirk that I need to know to get these images to show up correctly? Is there any way to verify that the program is loading the correct imageName#2x vs imageName? Is there some document that talks about integrated graphics (the iconography documentation isn't very helpful on technical details)
Actual Images
With Background:
Without Background:
I think you will find success if you just save the image at 4x the size you actually want and specify the size manually.
I have some images which are huge in size and my bundle size currently is 70 MB. I think Xcode already runs the assets through png crush.
Do not use any text images with useless effects, use UILabels instead.
Draw simple shapes and effects using CAShapeLayers instead of using
images.
Use JPEGs instead of PNGs where you don't need transparency.
(Actually file size depends on the image content here)
Use Save for Web option in PhotoShop or other tools to optimize PNG
images.
Use sprites combined together instead of separate images.
Make sure you delete all unused resources.
Do not localize common parts of the images, localize only the
different parts. (think of a background image with a small flag at
the bottom for each locale. use one single bg image and separate flag
images. localize flag images only, not the entire bg images with the
flags.)
Use the same splash images for iOS7 and previous iOS versions. (You
need to manually edit the JSON file in .xcassets)
Try using a CDN to download assets on the first launch.
In addition to images keep those in mind too:
Try replacing custom fonts with default system fonts if you don't
need them really.
Use MP3 audio files instead of WAV files. (or other
compressed formats)
Make sure you delete all unused 3rd party frameworks.
You can try converting the images to jpg (if they don't have any transparent regions).
Also try using http://imageoptim.com/
It seems very unlikely that you actually need huge images. After all, the screen is not huge. Thus, the most likely form of size reduction is to reduce the physical dimensions of the images to the size you are actually going to be displaying.
This saves bandwidth when the user downloads the image, reduces the size of the app on the user's hard disk (the device), and also saves memory at the time an image is loaded. It is a vast waste of RAM to load an image that is larger than the size at which it will be displayed; after all, remember, the memory involved rises exponentially with the square of the difference.
One option is to host the images on a CDN like OpenText and fetch them as part of app initialization, or whenever they are first needed. Obviously this is more coding, but projects like SDWebImage make it pretty easy:
https://github.com/rs/SDWebImage/tree/master/SDWebImage
It also gives you the flexibility to swap out those images later if you use caching headers.
I’m new in iOS and trying to make simple app with hierarchy of viewcontrollers. In the last one I wanna display scrollable image (which can also be zoomed at least x1,5), containing some small black and white picture and a piece of text. Initially I planned to make vector image, convert it to .jpg and use UIScrollView for displaying. But I found out that .jpg ( approx. 150 KB) didn’t provide a good quality for displaying text. As I have to use a lot of images I don’t want to increase image size. What is worse I also want it look good on retina display.
Can you recommend a way how to display image, containing text, with enough quality?
I mean that I don’t want the user see the separate pixels of letters in the text. Just like when you read text in your e-mail in iOS. Image size should be as small as possible. Planning physical size of image – approx. 5 cm x 15 cm.
Any help much appreciated
Thanks
To get good edges you would need to use png not jpg, which will make the image sizes much larger. I have a better suggestion, more code but better solution.
The answer is to not put the text into the image, but to draw it over it in real time.
You would:
associate text at some coordinate in the image (say a CGRect) with the image
create a uiimageview subclass that in the drawRect routine, after calling super, draws the text using the NSString categories on UIKit (which let you draw into a context)
To get going on this please create a small one vc project and get the subclass working there, then back port it to your primary project.
Is there a way to use an icns file as the image source for I guess a UIImage? Or pick out one of the representations and resize?
NSImage does not seem to be available in cocoa-touch.
In particular I'd like to use them for drawing in the imageView part of a UITableViewCell.
There is no built-in way to do this and I see little benefit in doing so. It's best to just use the sizes that you need and ship them as individual images in your app. If you want to draw the images in a UITableViewCell, performance is an important aspect and resizing images won't be fast.
If you really need images in many different sizes and really don't want the best performance by including images for each size, you could use a PDF to make use of vector graphics. There is a nice article about this technique: http://mattgemmell.com/2012/02/10/using-pdf-images-in-ios-apps/
Honestly, don't try to use .icns files in your iOS app. It's just a container for images of different sizes and resizing is not a good idea, anyway. Either include individual images for any size you need or use vector graphics using a PDF file.