I need to capture the principal layout on the screen, or just the whole screen if that is faster. I've tried two methods and both cause a noticable delay.
Method 1: drawing cache - takes about 80 ms
setDrawingCacheEnabled (true);
Bitmap oldLayout = Bitmap.createBitmap (getDrawingCache ());
setDrawingCacheEnabled (false);
Method 2: draw to canvas - takes about 50 ms
Bitmap oldLayout = Bitmap.createBitmap (getWidth (), getHeight (), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas (oldLayout);
int wSpec = MeasureSpec.makeMeasureSpec (getWidth (), MeasureSpec.EXACTLY);
int hSpec = MeasureSpec.makeMeasureSpec (getHeight (), MeasureSpec.EXACTLY);
measure (wSpec, hSpec);
layout (0, 0, getWidth (), getHeight ());
draw (canvas);
It seems that if I could capture directly from the screen that would be faster. I haven't seen a way to do that, however. Any other techniques worth trying?