Most visited

Recently visited

Added in API level 24

PixelCopy

public final class PixelCopy
extends Object

java.lang.Object
   ↳ android.view.PixelCopy


提供一种机制来发出像素复制请求以允许从 Surface到 Bitmap复制操作

Summary

Nested classes

interface PixelCopy.OnPixelCopyFinishedListener

监听器用于观察PixelCopy请求的完成情况。

Constants

int ERROR_DESTINATION_INVALID

目标不是有效的复制目标。

int ERROR_SOURCE_INVALID

无法从源文件复制。

int ERROR_SOURCE_NO_DATA

源文件没有任何可复制的内容。

int ERROR_TIMEOUT

尝试从源中获取要复制的缓冲区时发生超时。

int ERROR_UNKNOWN

像素复制请求失败,出现未知错误。

int SUCCESS

像素复制请求成功

Public methods

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

要求将 SurfaceView的显示内容复制到提供的 Bitmap 。

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

请求将 Surface中的像素副本复制到提供的 Bitmap 。

Inherited methods

From class java.lang.Object

Constants

ERROR_DESTINATION_INVALID

Added in API level 24
int ERROR_DESTINATION_INVALID

目标不是有效的复制目标。 如果目标是位图,则可能会发生位图太大而无法将硬件复制到位图的情况。 如果目的地已被销毁,也会发生这种情况。

常量值:5(0x00000005)

ERROR_SOURCE_INVALID

Added in API level 24
int ERROR_SOURCE_INVALID

无法从源文件复制。 如果源受到硬件保护或被破坏,就会发生这种情况。

常量值:4(0x00000004)

ERROR_SOURCE_NO_DATA

Added in API level 24
int ERROR_SOURCE_NO_DATA

源文件没有任何可复制的内容。 当源是Surface这意味着没有缓冲区已经排队。 等待信号源产生一帧,然后重试。

常量值:3(0x00000003)

ERROR_TIMEOUT

Added in API level 24
int ERROR_TIMEOUT

尝试从源中获取要复制的缓冲区时发生超时。

常量值:2(0x00000002)

ERROR_UNKNOWN

Added in API level 24
int ERROR_UNKNOWN

像素复制请求失败,出现未知错误。

常数值:1(0x00000001)

SUCCESS

Added in API level 24
int SUCCESS

像素复制请求成功

常量值:0(0x00000000)

Public methods

request

Added in API level 24
void request (SurfaceView source, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)

要求将SurfaceView的显示内容复制到提供的Bitmap 。 源的内容将被缩放以恰好位于该位图内。 源缓冲区的像素格式将作为副本的一部分进行转换,以适应位图Bitmap.Config 。 SurfaceView Surface中最近排队的缓冲区将用作副本的源。

Parameters
source SurfaceView: The source from which to copy
dest Bitmap: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap.
listener PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completes
listenerThread Handler: The callback will be invoked on this Handler when the copy is finished.

request

Added in API level 24
void request (Surface source, 
                Bitmap dest, 
                PixelCopy.OnPixelCopyFinishedListener listener, 
                Handler listenerThread)

请求将Surface中的像素副本复制到提供的Bitmap 。 源的内容将被缩放以恰好位于该位图内。 源缓冲区的像素格式将作为副本的一部分进行转换,以适应位图Bitmap.Config 。 Surface中最近排队的缓冲区将用作副本的来源。

Parameters
source Surface: The source from which to copy
dest Bitmap: The destination of the copy. The source will be scaled to match the width, height, and format of this bitmap.
listener PixelCopy.OnPixelCopyFinishedListener: Callback for when the pixel copy request completes
listenerThread Handler: The callback will be invoked on this Handler when the copy is finished.

Hooray!