ImageWriter Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The ImageWriter class allows an application to produce Image data into a
android.view.Surface
, and have it be consumed by another component
like android.hardware.camera2.CameraDevice CameraDevice
.
[Android.Runtime.Register("android/media/ImageWriter", ApiSince=23, DoNotGenerateAcw=true)]
public class ImageWriter : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.Lang.IAutoCloseable
[<Android.Runtime.Register("android/media/ImageWriter", ApiSince=23, DoNotGenerateAcw=true)>]
type ImageWriter = class
inherit Object
interface IAutoCloseable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- Inheritance
- Attributes
- Implements
Remarks
The ImageWriter class allows an application to produce Image data into a android.view.Surface
, and have it be consumed by another component like android.hardware.camera2.CameraDevice CameraDevice
.
Several Android API classes can provide input android.view.Surface Surface
objects for ImageWriter to produce data into, including MediaCodec MediaCodec
(encoder), android.hardware.camera2.CameraCaptureSession CameraCaptureSession
(reprocessing input), ImageReader
, etc.
The input Image data is encapsulated in Image
objects. To produce Image data into a destination android.view.Surface Surface
, the application can get an input Image via #dequeueInputImage
then write Image data into it. Multiple such Image
objects can be dequeued at the same time and queued back in any order, up to the number specified by the maxImages
constructor parameter.
If the application already has an Image from ImageReader
, the application can directly queue this Image into the ImageWriter (via #queueInputImage
), potentially with zero buffer copies. This even works if the image format of the ImageWriter is ImageFormat#PRIVATE PRIVATE
, and prior to Android P is the only way to enqueue images into such an ImageWriter. Starting in Android P private images may also be accessed through their hardware buffers (when available) through the Image#getHardwareBuffer()
method. Attempting to access the planes of a private image, will return an empty array.
Once new input Images are queued into an ImageWriter, it's up to the downstream components (e.g. ImageReader
or android.hardware.camera2.CameraDevice
) to consume the Images. If the downstream components cannot consume the Images at least as fast as the ImageWriter production rate, the #dequeueInputImage
call will eventually block and the application will have to drop input frames.
If the consumer component that provided the input android.view.Surface Surface
abandons the android.view.Surface Surface
, #queueInputImage queueing
or #dequeueInputImage dequeueing
an Image
will throw an IllegalStateException
.
Java documentation for android.media.ImageWriter
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
ImageWriter(IntPtr, JniHandleOwnership) |
Properties
Class |
Returns the runtime class of this |
DataSpace |
Get the ImageWriter dataspace. |
Format |
Get the ImageWriter format. |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
HardwareBufferFormat |
Get the ImageWriter hardwareBuffer format. |
Height |
The height of |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
MaxImages |
Maximum number of Images that can be dequeued from the ImageWriter
simultaneously (for example, with |
PeerReference | (Inherited from Object) |
ThresholdClass | |
ThresholdType | |
Usage |
Get the ImageWriter usage flag. |
Width |
The width of |
Methods
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Close() |
Free up all the resources associated with this ImageWriter. |
DequeueInputImage() |
Dequeue the next available input Image for the application to produce data into. |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
NewInstance(Surface, Int32, ImageFormatType) |
Create a new ImageWriter with given number of max Images and format. |
NewInstance(Surface, Int32) |
Create a new ImageWriter. |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
QueueInputImage(Image) |
Queue an input |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetOnImageReleasedListener(ImageWriter+IOnImageReleasedListener, Handler) |
Register a listener to be invoked when an input Image is returned to the ImageWriter. |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |