AndroidBrushFamilySerialization


@ExperimentalInkCustomBrushApi
public static class AndroidBrushFamilySerialization


Summary

Public methods

static final @NonNull BrushFamily
decode(
    @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.

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

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

Public fields

INSTANCE

Added in 1.0.0-alpha05
public static @NonNull AndroidBrushFamilySerialization INSTANCE

Public methods

decode

Added in 1.0.0-alpha05
public static final @NonNull BrushFamily decode(
    @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. Kotlin callers should use BrushFamily.Companion.decode instead.

getClientTextureId is called synchronously as part of this function call, on the same thread.

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.

encode

Added in 1.0.0-alpha05
public static final void encode(
    @NonNull BrushFamily brushFamily,
    @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 brushFamily

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.