AndroidBrushFamilyExtensions

Added in 1.0.0-alpha05

public final class AndroidBrushFamilyExtensions


Summary

Public methods

static final @NonNull BrushFamily

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful.

static final void
@ExperimentalInkCustomBrushApi
encode(
    @NonNull BrushFamily receiver,
    @NonNull OutputStream output,
    @NonNull TextureBitmapStore textureBitmapStore
)

Write a gzip-compressed ink.proto.BrushFamily binary proto message representing the BrushFamily to the given OutputStream.

Public methods

@ExperimentalInkCustomBrushApi
public static final @NonNull BrushFamily decode(
    @NonNull BrushFamily.Companion receiver,
    @NonNull InputStream input,
    @NonNull BrushFamilyDecodeCallback getClientTextureId
)

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful. Java callers should use AndroidBrushFamilySerialization.decode instead.

Parameters
@NonNull InputStream input

InputStream providing gzip-compressed ink.proto.BrushFamily binary proto messages, the same as written to OutputStream by encode.

@NonNull BrushFamilyDecodeCallback getClientTextureId

A callback to store the decoded texture image, if one were encoded inside the serialized BrushFamily, into a TextureBitmapStore. This is called synchronously as part of this function call on the same thread.

Returns
@NonNull BrushFamily

The BrushFamily parsed from the InputStream.

Throws
java.io.IOException

if gzip-format bytes cannot be read from input.

kotlin.IllegalArgumentException

input does not provide a valid ink.proto.BrushFamily proto message, or the corresponding BrushFamily is invalid.

@ExperimentalInkCustomBrushApi
public static final void encode(
    @NonNull BrushFamily receiver,
    @NonNull OutputStream output,
    @NonNull TextureBitmapStore textureBitmapStore
)

Write a gzip-compressed ink.proto.BrushFamily binary proto message representing the BrushFamily to the given OutputStream.

Parameters
@NonNull BrushFamily receiver

The BrushFamily object to encode.

@NonNull OutputStream output

The OutputStream to write the gzip-compressed encoded bytes to.

@NonNull TextureBitmapStore textureBitmapStore

The TextureBitmapStore to use to encode the texture images within the encoded BrushFamily. If this is not desired behavior, e.g. if the application has a static set of texture images that it includes as resources, then this can be a TextureBitmapStore that always returns null.