PixelCopy
public
final
class
PixelCopy
extends Object
| java.lang.Object | |
| ↳ | android.view.PixelCopy |
Provides a mechanisms to issue pixel copy requests to allow for copy
operations from Surface to Bitmap
Summary
Nested classes | |
|---|---|
interface |
PixelCopy.OnPixelCopyFinishedListener
Listener for observing the completion of a PixelCopy request. |
Constants | |
|---|---|
int |
ERROR_DESTINATION_INVALID
The destination isn't a valid copy target. |
int |
ERROR_SOURCE_INVALID
It is not possible to copy from the source. |
int |
ERROR_SOURCE_NO_DATA
The source has nothing to copy from. |
int |
ERROR_TIMEOUT
A timeout occurred while trying to acquire a buffer from the source to copy from. |
int |
ERROR_UNKNOWN
The pixel copy request failed with an unknown error. |
int |
SUCCESS
The pixel copy request succeeded |
Public methods | |
|---|---|
static
void
|
request(SurfaceView source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests for the display content of a |
static
void
|
request(Surface source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels at the provided |
static
void
|
request(SurfaceView source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests for the display content of a |
static
void
|
request(Window source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels at the provided |
static
void
|
request(Window source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels from a |
static
void
|
request(Surface source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels from a |
Inherited methods | |
|---|---|
java.lang.Object
| |
Constants
ERROR_DESTINATION_INVALID
int ERROR_DESTINATION_INVALID
The destination isn't a valid copy target. If the destination is a bitmap this can occur if the bitmap is too large for the hardware to copy to. It can also occur if the destination has been destroyed.
Constant Value: 5 (0x00000005)
ERROR_SOURCE_INVALID
int ERROR_SOURCE_INVALID
It is not possible to copy from the source. This can happen if the source is hardware-protected or destroyed.
Constant Value: 4 (0x00000004)
ERROR_SOURCE_NO_DATA
int ERROR_SOURCE_NO_DATA
The source has nothing to copy from. When the source is a Surface
this means that no buffers have been queued yet. Wait for the source
to produce a frame and try again.
Constant Value: 3 (0x00000003)
ERROR_TIMEOUT
int ERROR_TIMEOUT
A timeout occurred while trying to acquire a buffer from the source to copy from.
Constant Value: 2 (0x00000002)
ERROR_UNKNOWN
int ERROR_UNKNOWN
The pixel copy request failed with an unknown error.
Constant Value: 1 (0x00000001)
SUCCESS
int SUCCESS
The pixel copy request succeeded
Constant Value: 0 (0x00000000)
Public methods
request
void request (SurfaceView source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests for the display content of a SurfaceView to be copied
into a provided Bitmap.
The contents of the source will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the SurfaceView's Surface will be used as the source of the copy.
| Parameters | |
|---|---|
source |
SurfaceView: The source from which to copyThis value must never be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
request
void request (Surface source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels at the provided Rect from
a Surface to be copied into a provided Bitmap.
The contents of the source rect will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the Surface will be used as the source of the copy.
| Parameters | |
|---|---|
source |
Surface: The source from which to copyThis value must never be |
srcRect |
Rect: The area of the source to copy from. If this is null
the copy area will be the entire surface. The rect will be clamped to
the bounds of the Surface.This value may be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
request
void request (SurfaceView source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests for the display content of a SurfaceView to be copied
into a provided Bitmap.
The contents of the source will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the SurfaceView's Surface will be used as the source of the copy.
| Parameters | |
|---|---|
source |
SurfaceView: The source from which to copyThis value must never be |
srcRect |
Rect: The area of the source to copy from. If this is null
the copy area will be the entire surface. The rect will be clamped to
the bounds of the Surface.This value may be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
request
void request (Window source, Rect srcRect, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels at the provided Rect from
a Window to be copied into a provided Bitmap.
The contents of the source rect will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the Window's Surface will be used as the source of the copy.
Note: This is limited to being able to copy from Window's with a non-null
DecorView. If peekDecorView() is null this throws an
IllegalArgumentException. It will similarly throw an exception
if the DecorView has not yet acquired a backing surface. It is recommended
that ViewTreeObserver.OnDrawListener is used to ensure that at least one draw
has happened before trying to copy from the window, otherwise either
an IllegalArgumentException will be thrown or an error will
be returned to the PixelCopy.OnPixelCopyFinishedListener.
| Parameters | |
|---|---|
source |
Window: The source from which to copyThis value must never be |
srcRect |
Rect: The area of the source to copy from. If this is null
the copy area will be the entire surface. The rect will be clamped to
the bounds of the Surface.This value may be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
request
void request (Window source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels from a Window to be copied into
a provided Bitmap.
The contents of the source will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the Window's Surface will be used as the source of the copy.
Note: This is limited to being able to copy from Window's with a non-null
DecorView. If peekDecorView() is null this throws an
IllegalArgumentException. It will similarly throw an exception
if the DecorView has not yet acquired a backing surface. It is recommended
that ViewTreeObserver.OnDrawListener is used to ensure that at least one draw
has happened before trying to copy from the window, otherwise either
an IllegalArgumentException will be thrown or an error will
be returned to the PixelCopy.OnPixelCopyFinishedListener.
| Parameters | |
|---|---|
source |
Window: The source from which to copyThis value must never be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
request
void request (Surface source, Bitmap dest, PixelCopy.OnPixelCopyFinishedListener listener, Handler listenerThread)
Requests a copy of the pixels from a Surface to be copied into
a provided Bitmap.
The contents of the source will be scaled to fit exactly inside the bitmap.
The pixel format of the source buffer will be converted, as part of the copy,
to fit the the bitmap's Bitmap.Config. The most recently queued buffer
in the Surface will be used as the source of the copy.
| Parameters | |
|---|---|
source |
Surface: The source from which to copyThis value must never be |
dest |
Bitmap: The destination of the copy. The source will be scaled to
match the width, height, and format of this bitmap.This value must never be |
listener |
PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completesThis value must never be |
listenerThread |
Handler: The callback will be invoked on this Handler when
the copy is finished.
This value must never be |
Annotations
Interfaces
- ActionMode.Callback
- ActionProvider.VisibilityListener
- Choreographer.FrameCallback
- CollapsibleActionView
- ContextMenu
- ContextMenu.ContextMenuInfo
- GestureDetector.OnContextClickListener
- GestureDetector.OnDoubleTapListener
- GestureDetector.OnGestureListener
- InputQueue.Callback
- KeyEvent.Callback
- LayoutInflater.Factory
- LayoutInflater.Factory2
- LayoutInflater.Filter
- Menu
- MenuItem
- MenuItem.OnActionExpandListener
- MenuItem.OnMenuItemClickListener
- PixelCopy.OnPixelCopyFinishedListener
- ScaleGestureDetector.OnScaleGestureListener
- SubMenu
- SurfaceHolder
- SurfaceHolder.Callback
- SurfaceHolder.Callback2
- TextureView.SurfaceTextureListener
- View.OnApplyWindowInsetsListener
- View.OnAttachStateChangeListener
- View.OnCapturedPointerListener
- View.OnClickListener
- View.OnContextClickListener
- View.OnCreateContextMenuListener
- View.OnDragListener
- View.OnFocusChangeListener
- View.OnGenericMotionListener
- View.OnHoverListener
- View.OnKeyListener
- View.OnLayoutChangeListener
- View.OnLongClickListener
- View.OnScrollChangeListener
- View.OnSystemUiVisibilityChangeListener
- View.OnTouchListener
- ViewGroup.OnHierarchyChangeListener
- ViewManager
- ViewParent
- ViewStub.OnInflateListener
- ViewTreeObserver.OnDrawListener
- ViewTreeObserver.OnGlobalFocusChangeListener
- ViewTreeObserver.OnGlobalLayoutListener
- ViewTreeObserver.OnPreDrawListener
- ViewTreeObserver.OnScrollChangedListener
- ViewTreeObserver.OnTouchModeChangeListener
- ViewTreeObserver.OnWindowAttachListener
- ViewTreeObserver.OnWindowFocusChangeListener
- Window.Callback
- Window.OnFrameMetricsAvailableListener
- Window.OnRestrictedCaptionAreaChangedListener
- WindowManager
Classes
- AbsSavedState
- ActionMode
- ActionMode.Callback2
- ActionProvider
- Choreographer
- ContextThemeWrapper
- Display
- Display.HdrCapabilities
- Display.Mode
- DragAndDropPermissions
- DragEvent
- FocusFinder
- FrameMetrics
- FrameStats
- GestureDetector
- GestureDetector.SimpleOnGestureListener
- Gravity
- HapticFeedbackConstants
- InputDevice
- InputDevice.MotionRange
- InputEvent
- InputQueue
- KeyboardShortcutGroup
- KeyboardShortcutInfo
- KeyCharacterMap
- KeyCharacterMap.KeyData
- KeyEvent
- KeyEvent.DispatcherState
- LayoutInflater
- MenuInflater
- MotionEvent
- MotionEvent.PointerCoords
- MotionEvent.PointerProperties
- OrientationEventListener
- OrientationListener
- PixelCopy
- PointerIcon
- ScaleGestureDetector
- ScaleGestureDetector.SimpleOnScaleGestureListener
- SearchEvent
- SoundEffectConstants
- Surface
- SurfaceView
- TextureView
- TouchDelegate
- VelocityTracker
- View
- View.AccessibilityDelegate
- View.BaseSavedState
- View.DragShadowBuilder
- View.MeasureSpec
- ViewAnimationUtils
- ViewConfiguration
- ViewDebug
- ViewGroup
- ViewGroup.LayoutParams
- ViewGroup.MarginLayoutParams
- ViewGroupOverlay
- ViewOutlineProvider
- ViewOverlay
- ViewPropertyAnimator
- ViewStructure
- ViewStructure.HtmlInfo
- ViewStructure.HtmlInfo.Builder
- ViewStub
- ViewTreeObserver
- Window
- WindowAnimationFrameStats
- WindowContentFrameStats
- WindowId
- WindowId.FocusObserver
- WindowInsets
- WindowManager.LayoutParams
Enums
Exceptions