Reputation: 831
I am taking screen-shots or if better put in words I can say I am Creating Bitmap from a view's drawing cache in a loop in my application.
I am able to take screen-shots at the rate of 10 fps for Samsung galaxy tab 3 which is quite good. But, when I do the same thing on higher resolution devices like Nexus 7 the speed drops to 5 fps.
I am worried at the level of nexus 10 it may drop to 2 fps which will make my application crippled on bigger devices.
Can anyone suggest me a way through which this speed can be increased without rooting the device?
Upvotes: 1
Views: 179
Reputation: 831
I found the solution.
I was using view.getDrawingCache() which is slow process. Instead we can use View.draw(canvas) method.
while (running) {
try {
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
v1.draw(new Canvas(bitmap));
if (bitmap != null) {
bitmaps.addImage(bitmap);//add to arraylist
}
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println(" ArrayIndexOutOfBoundsException "
+ e.getMessage());
} catch (Exception e) {
System.err.println("EXCEPTION " + e.getMessage());
}
}
This code may throw array indexOutOfBound exception so I have catched it. It works as a Charm :)
Upvotes: 1