In this url the image has perfect resolution http://www.pikspeak.com/show.php?id=3&img=guitar
but when I am creating an .swf file for the same image the resolution is not that perfect. The link for the it is http://www.pikspeak.com/fb.swf?id=3&img=guitar
Can any one let me know how I can improve resolution in the .swf file. In the swf file I am
loading the image using loader.
loader= new Loader();
loader.load(url);
It is probably because you shrink the image. You can make it look better by applying smoothing once it is loaded, by doing Bitmap(loader.content).smoothing = true.
Related
One of our team member is urging to use SVGs using github.com/pocketsvg/PocketSVG, instead of regular assets #1x #2x #3x. We have over a hundred image sets.
I have 2 questions:
1) 100s of SVG data rendered using PocketSVG or even another library, is that gonna be a performance kill?
2) Using SVGs over regular assets, going to make any different visually, though our designer have these all images extracted properly using vectors.
Thanks in advance.
Answer for first Question : Yes, Whenever trying to show an image on the screen, it will process your SVG file and create a new image assets. May be the library can cache the image to avoid second time processing.
You no need to use PocketSVG if you have all SVG images on your Asset Catalog. Because Xcode Asset catalog itself able to handle the SVG images.
Xcode will create #1x #2x #3x images from SVG file at the time of compilation.
Answer for second Question : SVG is a vector image. You can extract good quality image from svg. You will not get any different by using #1x #2x #3x images or SVG image.
The advantage of using SVG is no need to create one more asset #4x if Apple introduced another different screen resolution devices. Just recompile the code Xcode will create on behalf of you
Refer the link : How to use vector in Xcode
I am aware xcode has introduced an option to provide a vector image(.pdf) so that we don't have to give a image for each dimension such as 1x,2x,3x
This saves lots of time and its really a good feature
But how to go about making an vector image in .pdf format.
As far as I know any png image can be saved as .pdf image does it mean it has been vectorized ?
or else we have to do it in the harder way .. by installing adobe illustrator and making an vector image through that
or else it there any web app that does it for us
basically I want to do the right way so the when image is displayed in 3x devices also there is no image distortion
This is a supplement to the excellent answer by #Senseful.
How to make vector images in .pdf format
I will tell how to do this in Inkscape since it is free and open source but other programs should be similar.
In Inkscape:
Create a new project.
Go to File > Document Properties and set the custom page size to whatever your #1x size is (44x44, 100x100, etc) with the units in px.
Make your artwork.
Go to File > Save As... > Printable Document Format (*.pdf) > Save > OK. (Alternatively, you could go to Print > Print to File > Output format: PDF > Print but there are not as many options.)
Notes:
As is mentioned in the accepted answer, you cannot resize your image because Xcode still produces the rasterized images at build time. If you need to resize your image you should make a new .pdf file with a different size.
If you already have an .svg image that is the wrong page size, do the following:
Change the page size (Inkscape > File > Document Properties)
Select all objects (Ctrl+A) on the work space and resize them to fit in the new page size. (Hold down Ctrl to keep aspect size.)
To convert an .svg file into a .pdf you can also find online utilities to do the job for you. Here is one example from this answer. This has the benefit of allowing you to set the .pdf size easily.
Further reading
Using Vector Images in Xcode 6
Original answer
In my project I am using an image asset that is based on a PDF icon:
I am now using this image in a UIButton but the image takes up too much space. Is there an elegant way to set the size of the image:
Xcode converts PDF image assets to bitmaps at build time, so at runtime you actually aren't dealing with a vector image. Hence you can't actually do perfect scaling. For this reason it's best to have a separate image asset for your button if its size is different.
I have to create a custom photolib like the default one, with animation etc. I had some doubts..
1. Doubt
Should I create 3 images (Thumbnail image, 320*480 image to display full image and original size image in case user share the image) (I am storing this all in app doc directory)
Or should I only store the original image and crop them wen required in 2 other images? In this case, if I use scroll view to display cropped images, how do I know what the user is seeing? And when do I crop next images to keep them ready to display?
(Can anything like reusable cells be created here like in tableview? If yes, can you give me some idea?)
Also, I am fetching images from doc directory. In this case should I load all images in Array or load in batches?
2. Problem Major:
Also need to compress original image and keep it of same size (I used uijpegrepresentation with compression ratio but with some jpegs after compression. It increases sizes even double the size).
You can use single image and for thumbnail you can Resize at run time else it increase size and performance issue. there is lots of open source library are there which do same what you needed. Please have a look below.
https://github.com/arturgrigor/AGImagePickerController
https://github.com/gdavis/FGallery-iPhone
I'm fiddling with the iOS startup image.
Both tutorials I found
http://mathiasbynens.be/notes/touch-icons
https://gist.github.com/472519
are using .png images for the splash screen. I have tried to reduce my png files size, but for the large splashscreens, I'm well over 500k, which is too much for me. So I tried using jpg, which also seems to work, but I'm not sure I'm doing the right thing when switching from PNG to JPG.
Here is my code for inserting the splash screen (lost the link to the original author... :-(
It's inserted as script, because iOS is said to load every specified image although only one image is needed. The script ensures only a single splash screen is inserted into the DOM and thus avoids unnecessary http requests.
<script>
(function(){var a;if(navigator.platform==="iPad") {
a=window.orientation===90||window.orientation===-90 ?
"landscape.jpg" : "portrait.jpg"
} else {
a=window.devicePixelRatio === 2 ? "retina.jpg" : "startup.jpg"
}
document.write('<link rel="apple-touch-startup-image" href="'+a+'"/>')})()
</script>
My questions:
1. Should I use JPG over PNG to cut down on file size?
2. How can I reduce my PNG file size? (I used optipng, but 20% of 800k is still 640k)
Thanks for hints!
I use JPG files on my site and they work just fine. Just make sure you optimize for web when you save, and make sure the image dimensions are exactly correct. See here (the page mainly talks about splash images for an actual native app, but the information also applies to web apps): http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html