android.view.PixelCopy Java Examples
The following examples show how to use
android.view.PixelCopy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewUtils.java From AndroidAnimationExercise with Apache License 2.0 | 7 votes |
@RequiresApi(api = Build.VERSION_CODES.O) public static void getBitmapFormView(View view, Activity activity, Callback callback) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); int[] locations = new int[2]; view.getLocationInWindow(locations); Rect rect = new Rect(locations[0], locations[1], locations[0] + view.getWidth(), locations[1] + view.getHeight()); PixelCopy.request(activity.getWindow(), rect, bitmap, copyResult -> { if (copyResult == PixelCopy.SUCCESS) { callback.onResult(bitmap); } }, new Handler(Looper.getMainLooper())); }