I have a image (resolution 8328x3987). And I want to load that image in my app with zoom controls for better viewing.
As we all know that Android will not load large images directly on device (like in my example). So Android system suggested us to scale down the image to load large images. I have tried this and scale my image upto four times as:
options.inSampleSize = 4;
Using this way my image will displayed on screen, but when I zoom-in the image then this image becomes unreadable (text becomes very blurry), this is because, maybe I scale down the image before showing?
But when I see that image in to device's default gallery app (Android Lollipop, Photos app), then this image looks like a mapview (only visible portion is readable and outside is blurry, and when I move the image then visible area becomes readable) when I zoomed in at max level. So my questions is:
Is Android lollipop added any new way to load large files that looks like mapview?
If not, then do you have an idea how that apps do this or any example?
Reducing the sample size of an image that big will not work at all.(very very bad resolution and memory consumption)
I suggest you to divide image to tiles and recycle the views just like map views do.
This library may help you. Or you can do it your way too.
Related
I have png images that have drop shadow. There is no unproportional images scaling problem, scaling are according to the aspect ratio.
When I using Image.asset() for placing images on phone screen, they're and their shadows looks low quality and not soft.
Original image looks: http://prnt.sc/p93vo2
Image on Android App: https://prnt.sc/p93vz3
Example images are same and 700x400, 96dpi.
You should see quality difference between images.
There is also a strange stuation. The shadow density on right and bottom side is more than shadow of original image on android app.
I've tried FilterQuality.high but no change, how to fix it?
In my case, the problem was due to a bad configuration of the image resolution system.
Full answer SO: Images loose quality when using image.asset in flutter
.
I am writing a Android app which need to display some high quality picture(took from professional DSLR). The problem is it can't be display from gallery.
I choose a photo in Gallery first. The target picture is 2464*1632 JPEG, roughly 4.5M;
Then I just need to compress it to 800*600 and display it in imageview:
image.setImageBitmap(this.bmp);
Thing is that I have tested other image I downloaded form internet(really low quality), and it works without any problem. Can anybody tell me why it can't be displayed? I will be really appericiated
Large images are tricky to handle due to limited memory. You have several choices:
Use a WebView (this allows you to have pinch and zoom functionality to make use of those extra pixels
Decode the image down to the size of the display and then put it in an ImageView using BitmapOpts http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html and changing inSampleSize. It seems you may be having difficulty with that, so consider using createScaledBitmap which just needs the dest width and height.
I have some large images that I would like to display to the user. I want them to have the ability to zoom in. I am currently using TouchImageView, and it is working, however, the quality/resolution of the image does not change as I zoom in.
I noticed that some of the Gallery apps appear to be doing this. They load the entire image, at some sampling rate so that it can be displayed without an out of memory. Then as you zoom in, it appears that the quality of the image is getting increased.
Is there example code/library for functionality similar to this?
If you have 1 source image and are zooming in on it you aren't going to magically create resolution where there was none previously. The answer is to either create multiple r-sets or multiple images with different resolutions and load/zoom/scale dynamically, OR downsample the image yourself when displaying it zoomed out at a lower resolution.
For example, consider thumbnail images. They are created as a small sample of the original image. If you zoomed in on that thumbnail it would look horrible. You calculate the best r-set image based on the zoom level and coordinates of your client view.
I think my preference would be to preprocess the large images and create different levels of resolution as I mentioned in the first paragraph. Then as the user zooms in you load a different image. This is similar to how Google maps works for example.
I hope this helps.
I suggest that you use the view provided by Dave Morrissey:
Subsampling Scale Image View
An excerpt from the source:
A custom ImageView for Android with pinch to zoom and subsampled tiles
to support large images. While zooming in, the low resolution, full
size base layer is overlaid with smaller tiles in the best resolution
for the current scale, and tiles are loaded and discarded during
panning to avoid holding too much bitmap data in memory.
I do have some images (example) which will be displayed differently depending on the software I am using.
When I open the image in my browser, the picture loads from the right side to the left (in contrast to other images which are loading from top to bottom).
Browser:
When I display the same image in an Android Application (via UrlImageViewHelper) the image will be displayed with an rotation of 90°.
Android:
'Normal' Images (that are loading from the top downwards) are being displayed correctly in my application.
Questions
Where does the browser get the information about the orientation of the image?
How could I implement an Android ImageView that is aware of the original orientation of the image?
Try this:
Put the rotated jpeg in your res/drawable. Set an ImageView to use that. See what happens.
UrlImageViewHelper doesn't actually do special image loading. It just uses the BitmapFactory like it should.
This is very likely to be an Android framework/libjpeg bug where jpeg rotation EXIF tag is not being honored.
I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.