AndroidBrushFamilySerialization


public static class AndroidBrushFamilySerialization


Summary

Public methods

static final @NonNull BrushFamily
decode(
    @NonNull InputStream input,
    @NonNull BrushFamilyDecodeCallback getClientTextureId
)

See decode above.

static final @NonNull BrushFamily
decode(
    @NonNull InputStream input,
    @NonNull Version maxVersion,
    @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
public static @NonNull AndroidBrushFamilySerialization INSTANCE

Public methods

decode

Added in 1.0.0
public static final @NonNull BrushFamily decode(
    @NonNull InputStream input,
    @NonNull BrushFamilyDecodeCallback getClientTextureId
)

See decode above. This overload uses Version.MAX_SUPPORTED.

decode

Added in 1.1.0-alpha02
public static final @NonNull BrushFamily decode(
    @NonNull InputStream input,
    @NonNull Version maxVersion,
    @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 Version maxVersion

The maximum Version supported by the deserializer. If the serialized BrushFamily has a min_version of greater than maxVersion, deserialization will fail.

@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.

IllegalArgumentException

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

encode

Added in 1.0.0
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. If hasFallbacks is true, then the stored, proto message including fallbacks for this BrushFamily will be used instead of recomputing the proto from the BrushFamily object.

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.