# PixelCopy

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/view/PixelCopy#nestedclasses)\|[Constants](https://developer.android.com/reference/android/view/PixelCopy#constants)\|[Methods](https://developer.android.com/reference/android/view/PixelCopy#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/view/PixelCopy#inhmethods)  

# PixelCopy

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/PixelCopy "View this page in Kotlin")\|Java

`
public

final

class
PixelCopy
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.PixelCopy |

<br />

*** ** * ** ***

Provides a mechanisms to issue pixel copy requests to allow for copy operations from[Surface](https://developer.android.com/reference/android/view/Surface)to[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)

## Summary

|                                                                                               ### Nested classes                                                                                                ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener) Listener for observing the completion of a PixelCopy request. |
| ` class`     | [PixelCopy.Request](https://developer.android.com/reference/android/view/PixelCopy.Request) Represents a PixelCopy request.                                                                       |
| ` class`     | [PixelCopy.Result](https://developer.android.com/reference/android/view/PixelCopy.Result) Contains the result of a PixelCopy request                                                              |

|                                                                                     ### Constants                                                                                      ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [ERROR_DESTINATION_INVALID](https://developer.android.com/reference/android/view/PixelCopy#ERROR_DESTINATION_INVALID) The destination isn't a valid copy target.                |
| `int` | [ERROR_SOURCE_INVALID](https://developer.android.com/reference/android/view/PixelCopy#ERROR_SOURCE_INVALID) It is not possible to copy from the source.                         |
| `int` | [ERROR_SOURCE_NO_DATA](https://developer.android.com/reference/android/view/PixelCopy#ERROR_SOURCE_NO_DATA) The source has nothing to copy from.                                |
| `int` | [ERROR_TIMEOUT](https://developer.android.com/reference/android/view/PixelCopy#ERROR_TIMEOUT) A timeout occurred while trying to acquire a buffer from the source to copy from. |
| `int` | [ERROR_UNKNOWN](https://developer.android.com/reference/android/view/PixelCopy#ERROR_UNKNOWN) The pixel copy request failed with an unknown error.                              |
| `int` | [SUCCESS](https://developer.android.com/reference/android/view/PixelCopy#SUCCESS) The pixel copy request succeeded                                                              |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.Surface,%20android.graphics.Rect,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[Surface](https://developer.android.com/reference/android/view/Surface)` source, `[Rect](https://developer.android.com/reference/android/graphics/Rect)` srcRect, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests a copy of the pixels at the provided[Rect](https://developer.android.com/reference/android/graphics/Rect)from a[Surface](https://developer.android.com/reference/android/view/Surface)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap). |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.SurfaceView,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)` source, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests for the display content of a[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap).                                                                                                                                                                          |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.SurfaceView,%20android.graphics.Rect,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)` source, `[Rect](https://developer.android.com/reference/android/graphics/Rect)` srcRect, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests for the display content of a[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap).                                                                |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.Window,%20android.graphics.Rect,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[Window](https://developer.android.com/reference/android/view/Window)` source, `[Rect](https://developer.android.com/reference/android/graphics/Rect)` srcRect, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests a copy of the pixels at the provided[Rect](https://developer.android.com/reference/android/graphics/Rect)from a[Window](https://developer.android.com/reference/android/view/Window)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap).      |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.Window,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[Window](https://developer.android.com/reference/android/view/Window)` source, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests a copy of the pixels from a[Window](https://developer.android.com/reference/android/view/Window)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap).                                                                                                                                                                                                    |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.PixelCopy.Request,%20java.util.concurrent.Executor,%20java.util.function.Consumer<android.view.PixelCopy.Result>))`(`[PixelCopy.Request](https://developer.android.com/reference/android/view/PixelCopy.Request)` request, `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)` callbackExecutor, `[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<`[PixelCopy.Result](https://developer.android.com/reference/android/view/PixelCopy.Result)`> listener) ` Executes the pixel copy request                                                                                                                                                                                                                                                                                                                                                                                     |
| ` static void` | ` `[request](https://developer.android.com/reference/android/view/PixelCopy#request(android.view.Surface,%20android.graphics.Bitmap,%20android.view.PixelCopy.OnPixelCopyFinishedListener,%20android.os.Handler))`(`[Surface](https://developer.android.com/reference/android/view/Surface)` source, `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)` dest, `[PixelCopy.OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener)` listener, `[Handler](https://developer.android.com/reference/android/os/Handler)` listenerThread) ` Requests a copy of the pixels from a[Surface](https://developer.android.com/reference/android/view/Surface)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap).                                                                                                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Constants

### ERROR_DESTINATION_INVALID

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final 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.

<br />

Constant Value: 5 (0x00000005)  

### ERROR_SOURCE_INVALID

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_SOURCE_INVALID
```

It is not possible to copy from the source. This can happen if the source is hardware-protected or destroyed.

<br />

Constant Value: 4 (0x00000004)  

### ERROR_SOURCE_NO_DATA

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_SOURCE_NO_DATA
```

The source has nothing to copy from. When the source is a[Surface](https://developer.android.com/reference/android/view/Surface)this means that no buffers have been queued yet. Wait for the source to produce a frame and try again.

<br />

Constant Value: 3 (0x00000003)  

### ERROR_TIMEOUT

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_TIMEOUT
```

A timeout occurred while trying to acquire a buffer from the source to copy from.

<br />

Constant Value: 2 (0x00000002)  

### ERROR_UNKNOWN

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_UNKNOWN
```

The pixel copy request failed with an unknown error.

<br />

Constant Value: 1 (0x00000001)  

### SUCCESS

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int SUCCESS
```

The pixel copy request succeeded

<br />

Constant Value: 0 (0x00000000)

## Public methods

### request

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (Surface source, 
                Rect srcRect, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests a copy of the pixels at the provided[Rect](https://developer.android.com/reference/android/graphics/Rect)from a[Surface](https://developer.android.com/reference/android/view/Surface)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/Bitmap.Config). The most recently queued buffer in the Surface will be used as the source of the copy.

<br />

|                                                                                       Parameters                                                                                       ||
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `Surface`: The source from which to copy This value cannot be`null`. <br />                                                                                          |
| `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. <br /> |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br />           |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                                       |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                                |

### request

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (SurfaceView source, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests for the display content of a[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/Bitmap.Config). The most recently queued buffer in the SurfaceView's Surface will be used as the source of the copy.

<br />

|                                                                                  Parameters                                                                                  ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `SurfaceView`: The source from which to copy This value cannot be`null`. <br />                                                                            |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br /> |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                             |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                      |

### request

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (SurfaceView source, 
                Rect srcRect, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests for the display content of a[SurfaceView](https://developer.android.com/reference/android/view/SurfaceView)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/Bitmap.Config). The most recently queued buffer in the SurfaceView's Surface will be used as the source of the copy.

<br />

|                                                                                       Parameters                                                                                       ||
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `SurfaceView`: The source from which to copy This value cannot be`null`. <br />                                                                                      |
| `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. <br /> |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br />           |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                                       |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                                |

### request

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (Window source, 
                Rect srcRect, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests a copy of the pixels at the provided[Rect](https://developer.android.com/reference/android/graphics/Rect)from a[Window](https://developer.android.com/reference/android/view/Window)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/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[Window.peekDecorView()](https://developer.android.com/reference/android/view/Window#peekDecorView())is null this throws an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException). It will similarly throw an exception if the DecorView has not yet acquired a backing surface. It is recommended that[OnDrawListener](https://developer.android.com/reference/android/view/ViewTreeObserver.OnDrawListener)is used to ensure that at least one draw has happened before trying to copy from the window, otherwise either an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)will be thrown or an error will be returned to the[OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener).

<br />

|                                                                                       Parameters                                                                                       ||
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `Window`: The source from which to copy This value cannot be`null`. <br />                                                                                           |
| `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. <br /> |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br />           |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                                       |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                                |

### request

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (Window source, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests a copy of the pixels from a[Window](https://developer.android.com/reference/android/view/Window)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/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[Window.peekDecorView()](https://developer.android.com/reference/android/view/Window#peekDecorView())is null this throws an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException). It will similarly throw an exception if the DecorView has not yet acquired a backing surface. It is recommended that[OnDrawListener](https://developer.android.com/reference/android/view/ViewTreeObserver.OnDrawListener)is used to ensure that at least one draw has happened before trying to copy from the window, otherwise either an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)will be thrown or an error will be returned to the[OnPixelCopyFinishedListener](https://developer.android.com/reference/android/view/PixelCopy.OnPixelCopyFinishedListener).

<br />

|                                                                                  Parameters                                                                                  ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `Window`: The source from which to copy This value cannot be`null`. <br />                                                                                 |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br /> |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                             |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                      |

### request

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (PixelCopy.Request request, 
                Executor callbackExecutor, 
                Consumer<PixelCopy.Result> listener)
```

Executes the pixel copy request

<br />

|                                                       Parameters                                                       ||
|--------------------|----------------------------------------------------------------------------------------------------|
| `request`          | `PixelCopy.Request`: The request to execute This value cannot be`null`. <br />                     |
| `callbackExecutor` | `Executor`: The executor to run the callback on This value cannot be`null`. <br />                 |
| `listener`         | `Consumer`: The callback for when the copy request is completed This value cannot be`null`. <br /> |

### request

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void request (Surface source, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)
```

Requests a copy of the pixels from a[Surface](https://developer.android.com/reference/android/view/Surface)to be copied into a provided[Bitmap](https://developer.android.com/reference/android/graphics/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 bitmap's[Bitmap.Config](https://developer.android.com/reference/android/graphics/Bitmap.Config). The most recently queued buffer in the Surface will be used as the source of the copy.

<br />

|                                                                                  Parameters                                                                                  ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`         | `Surface`: The source from which to copy This value cannot be`null`. <br />                                                                                |
| `dest`           | `Bitmap`: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap. This value cannot be`null`. <br /> |
| `listener`       | `PixelCopy.OnPixelCopyFinishedListener`: Callback for when the pixel copy request completes This value cannot be`null`. <br />                             |
| `listenerThread` | `Handler`: The callback will be invoked on this Handler when the copy is finished. This value cannot be`null`. <br />                                      |