I want to implement an application like "The star Epaper" available on Android and Apple Markets. This app is pretty amazing: it uses an small images but if u pinch this image, the quality of texts never change. It means by zoom in or zoom out the quality of image is still same. I went to files of app and found that there is a jpg image ( i.e. 183 KB) and each image has another file "22 KB" with no-extension. I used openwith and found that this file is also an image. Therefore, This app is using both of these images ( maybe one of the is vector) to replace the good quality for text file whenever pinch event fired.
What is this technique ? and how to implement it?
Correct, you need a file format that stores text as vector graphics. For example .pdf or .svg.
You can display such files using WebView on Android or UIWebView on iOS.
If you want more control, you can also implement your own view with zoom behavior. At each zoom level, you scale the text and render it again using the operating system's drawing API. There won't be any jaggies.
If you don't want to use web views, and don't want to do everything yourself either, look around SO: .svg libraries have been covered for example
here for iOS: How to render SVG images in iphone without uiwebview?
and here for Android: SVG support on Android .
Related
I am working in react native with Image component and I have to use same image at multiple locations with different size. Like user profile image at:
In profile section, with a large circle of about half the device height - 600x600px,
In others contact section in the list of the contacts as thumbnail image - 80x80px,
In chatting section, sending an image to other user, image message will appear in a small box -200x200px.
My concern is should I create a small exact image size crop/compressed version for each sizes above or I must use the original size image like 1000x1000 everywhere, irrespective of the Image component size
If I create a crop version of each image of perfect size than a lot of memory will be used on device and
If I use the original image (downloaded off-course) then react-native Image component may need to do lot of efforts to crop it to perfect size. This may leads to performance issue.
Please help with the correct approach.
Since react native follows the pattern of the web so it is smart enough to compress the image size to make it to the size of the Image component you are using, it may take some time for compressing the size, which seems a more viable solution rather than creating a compressed copy by yourself for each asset. Assets may keep on changing so it will be difficult to track.
You need to put logic on the server side. When you tried to upload an image then the server will resize the image in the necessary resolution which you need to use in application along with Original.
You need to render a particular image from the server on a particular screen. For downloading an image you can use FastImage.
I am making an app and part of it will view PDF's. The pdf's are on a web server and downloaded to the app. I am trying to understand what happens when a viewer loads a pdf. If it is converted to an image then I would like to try converting the pdf to a png on the server and just using that copy to view in app as png is a lot less hassle to deal with.
The only reason I would not convert to png is if an android pdf viewer maintains the vector nature of the file as zooming is critical and I want a nice crisp image.
Ultimately someone is always going to convert the PDF to an image. Or better said to pixels because that is what you need to display on the tablet screen (or any screen that I know of). The question is who does the conversion, when it is done and how well and quickly it is done.
For a tablet viewer, the challenge is to do the conversion quickly enough not to bother the user with load times and that often goes at the price of quality. There are virtually no PDF viewing applications on either iOS or Android at this point that do a really good job at showing all intricacies of the PDF file format.
That being said, the quality is usually good enough and if the viewer is well implemented, zooming for a PDF file should be a no brainer. Zooming simply means for the application that the viewport (the part of the PDF page that is visible) is different, but it doesn't really change the algorithm used to convert the PDF page elements into pixels.
That is also the difference between you converting the PDF to an image on the server and the app converting it to pixels on the device. Your server likely has more calculation power (at least it might have :-)) but the application knows at which resolution it needs to convert to pixels and what part of the page it has to convert to pixels. And a good viewing application can use these details to adapt how it does the conversion to pixels. There are lots of optimisation algorithms that can be used to only render visible elements and take shortcuts based on knowing exactly what resolution will be used for rendering.
In short, yes, you can do the rendering on the server and feed an image to your viewer. But keep in mind that - especially while allowing the user to zoom - you'll get lots of data and probably poorer quality than when you let a good viewer handle things in PDF...
I've been struggling for a long time with large images that are able to zoom. I am loading some picture from the network that can have very variable size: it might go from 0.5MP up to 10MP. Simply loading one to a bitmap can produce application crash because of OOM exception. But details are very important so I want the user to be able to zoom on them such that full quality is maintained (so the picture should refine itself during zooming). I don't find a proper way to do this. I've used the TouchImageView library, but it doesn't manage large pictures at all. If I first down sample my picture with the inSampleSize parameter of the BitmapFactory, I lose the quality definitively. I don't want to code a whole new zooming tool, as it is already implemented on every android phone in the default Gallery app. There has to be a way to use this kind of tool, and simply display a large image that is able to zoom, right?
Have you tried PhotoView?
You could also do it with loadUrl(String) of standard WebView which should handle big images too. WebView has built-in zoom controls.
BitmapRegionDecoder(added in 2.3.3) may work. But I've not tried it.
It seems that the implementation in Gallery is OpenGL, there is no way to use it simply.
I am looking to use these icons in my app
http://developer.android.com/design/downloads/index.html
But the problem is that these are only available in small sizes(~64x64) and if i try to expand it using some online tools, then they become very blurry. Is there any way to get these icons in 256x256 size or enlarging these icons but without blurring?
Thanks
It IS possible. But it requires some work.
The icons are distributed with an .ai file (like All_Icons.ai), which the extension for Adobe Illustrator image file.
Each icon is in its own layer in that file.
Adobe Illustrator is a vector image software, I mean it's not a bitmap image, so it can be enlarged without losing quality to any size.
However, it also means you need a software that can handle .ai file.
If you have Adobe Illustrator, open the .ai file, and find the layer that you want, go to layer menu and select "hide other layers", and save the image for web. In the saving for web dialog, you can select the image size for png, jpg, or gif file. (you can change the color or opacity if you need)
There is an accompanying .ai (Adobe Illustrator) file which has Vector images for all the .png's that are included in the various downloads. And since they are Vectors, you can resize them to your liking without worrying about distortion or pixelation.
Alternatively, you can generate your image resources using the Android Asset Studio, specifically, the Generic Icons option in the Android Asset Studio. They use the same Icons that you find on the Android Downloads page. I haven't compared if they are the exact number of images though.
A note about the Android Asset Studio (Generic Icons) though. You can only generate image resources in dp sizes and not px as you want them to be. That can be mitigated by using this converter here: http://labs.rampinteractive.co.uk/android_dp_px_calculator/
In my opinion you can't enlarge smaller images, this will always result in the loss of quality. Try finding similar images with 256x256 resolution.
I am currently working on an application that requires the use of a WebView. It basically takes up the entire screen space.
Initially the images inside of the WebView look fine and high quality. Unfortunately, when a user taps (and holds) a button in the webview, the images then lose quality and dither until the finger is released. Is there any way to disable this?
A good note, my app does not need any scrolling whatsoever. I thought Android would only lower the quality on scroll to better performance.
the only solution is to make your own image viewer, the webview resamples images at lower qualities
I've been dealing with the same issue for a long while. The best solution is to split the image into several sub-images and load them altogether within the same html file.
The easiest and fastest solution I found is with Adobe Photoshop:
Open you image
Create horizontal and vertical guides
Select the Slicing tool and activate the "create slices from guides"
Save for web (I'm not using the English version, but you get what I mean)
Select your desired image format
Save, but while saving check the option "Html and images"
With this, you'll avoid dithering with any image as long as you split it into enough pieces,