withUnsafeBytes(as:_:)
Encode a representation of this image in a given image format.
Declaration
borrowing func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> RParameters
- imageFormat:
The image format to use when encoding this image.
- body:
A function to call. A temporary buffer containing a data representation of this instance is passed to it.
Return Value
Whatever is returned by body.
Discussion
The testing library uses this function when saving an image as an attachment. The implementation should use imageFormat to determine what encoder to use.