how to speed up display for continous images in android - android

Currently, I am trying an application for receive and display views from another mobile. When views received, I will convert it as a bitmap, and use ImageView to display them like
imageView.setImagebitmap(xxx). However, I found the API performance is not good.
As I need display the continous images (not a video), is there any method to speed up the display?
Thank you

You should consider using SurfaceView instead of ImageView. Every time you call ImageView.setImageBitmap new BitmapDrawable instance is created and view itself is invalidated so this is quite heavy way for switching images rapidly.
Also if you need to scale bitmap before drawing you can dramatically increase framerate by disabling bitmap filtering.

Related

How to use high resolution images in a way that application don't lag?

High/medium resolution photo takes time to load from drawable and affects application performance, whereas low resolution photo looks blurred; I want to use high resolution images but not compromise with the performance, How to do that?
I am trying to set a high resolution background image of layout login from drawable, so when switching between components of the same activity lagging occurs.
For instance: switching between field email to password, keyboard appears/disappear in slow motion.
If I were you , I would use the Glide library. Its faster than Picasso and ideal when you want to load large images.
From the github documentation :
Glide's primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image
Yes, use Piccaso. It will adjust and load a correct image size depending on your device and size of imageview.
Hard to know what you need, but you can use a FrameLayout to download multiple pictures in the background and set them invisible till you need it with android:visibility attribute.This solution is for one activity. Asynchronous work and cache can be the answer.
You should consider resize your pic anyway, users prefer see the pic than wait and quit, they know the limitations of their devices (so does android ;-).

android: most efficient way to repeat an image

I am doing a project where I want 100 of the same image randomly scattered throughout the screen. In the future, I want an image to disappear when the image is tapped by the user.
I am mainly focusing right now on the most efficient way to display a repeated image. It seems like I could set it up so that the fact that the images are the same makes it more efficient; I'm just not sure how. I do not want to proceed further until I know I have a sound base. I'm using .png files.
I've looked around without a definite answer.
Also, would if be easier to draw my object with two circles (which is what my image is), rather than using a bitmap?
Any clues???
Assuming you're talking about drawing the bitmap on a Canvas object, the method should be pretty straightforward. You load the image into a Bitmap object and keep it as a member of the owning class, and draw it 100 times using canvas.drawBitmap(...) functions.
The other way of doing it is having 100 ImageViews with the same image, but I won't even write the details because this would be truly inefficient!
You can use a listView: http://developer.android.com/guide/topics/ui/layout/listview.html
It shows a list of items, using an adapter to inflate elements. It is pretty simple to use.

setting 3000X2000 pixel image as canvas background without resizing and avoiding outofmemorybound

i was wondering if is it efficient and possible to set 3000X2000px image as canvas background without resizing it and without getting the memory error.
because i want the real size image and pan around it.
using webview is not an option.
Currenty i tried to the set the background by using a folder structure named "Drawable-nodpi" and then assinging the bitmap image with decoderesource method.
Such a huge picture will inevitably cause outofmem exceptions on at least some devices. So I think that you need to dynamically scale and load only parts of the image that needs to be displayed, possibly with a caching mechanism.
Unfortunately, I don't know about any library components for Android that does this for you out of the box, but I'm pretty sure that you can find some nice articles on this topic.

Using BitmapRegionDecoder to load large images

I am trying to load a very large image from the internet in an android tablet application. I know how to load a smaller size sample but have noticed it hampers the resolution of the images. The android docs tell me about the BitmapRegionDecoder to help loading the images in tiles but there does not seem to be much documentation on it.
I am doing something like this:-
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(inputstream, false);
I understand that i have to loop through the below code as many times as required to get the entire image by passing different rect objects
region = decoder.decodeRegion(new Rect(0, 0, 50, 50), null);
But i fail to understand how to put all these bits in the right position in one imageview. Any example would be really helpful
What you are trying to do sounds like you want to defy the purpose of the region decoder. You could as well try to load the whole huge bitmap instead of pieces and joining them together. In the end you would risk an out of memory error either way. The point of the region decoder is getting just a clip from a huge bitmap. One use case could be a map view that can be panned with swipe gestures. You would calculate only the currently visible clip of the bitmap load that with the region decoder and display that in your map view. What you need to do is in fact loading a scaled version.
Yes you can use a BitmapRegionDecoder to view large Images based on Tiles
This guy here implemented a TileBitmapDrawable Class, that you can hook to your imageview:
https://github.com/diegocarloslima/ByakuGallery

Android calling GLUtils.texImage2D within onDrawFrame very slow

We are building a scrollable background, and currently have one large background image that we split up into 512x512 tiles, and want to load these tiles as they are needed, instead of all at once, when calling GLUtils.texImage2D within onDrawFrame, we have noticeable lag we think because of having to load the texture onto the hardware, is there a better way to do this?
Thanks.
Use texSubImage2D() to reload existing texture objects instead of creating entirely new ones.
G'day buddy,
I think the sheer amount of image data you're trying to transfer within a frame time is a tad much: if you are using a 24bpp format, 512x512 amounts to 1 MB of data. I can think of two ways to minimize it:
Change to a bitmap format that has less bpp. If you are using ARGB8888 you might want to try switching to RGB565 (as it is a background) to halve the data.
Consider splitting up the 512x512 into e.g. 4 chunks of 512x128 (since you are scrolling vertically). This way you distribute the loading over more frame intervals.
Cheers, Aert.

Categories

Resources