# BrushFamilySerialization

Artifact: [androidx.ink:ink-storage](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/storage/BrushFamilyExtensions.jvmAndAndroid.kt+class:androidx.ink.storage.BrushFamilySerialization) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- android

  ```
  object BrushFamilySerialization
  ```

*** ** * ** ***

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(kotlin.ByteArray,androidx.ink.storage.OnDecodeTexturePngBytes)(input: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html, onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes)` See `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(kotlin.ByteArray,androidx.ink.storage.OnDecodeTexturePngBytes)` above. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.OnDecodeTexturePngBytes)(input: https://developer.android.com/reference/java/io/InputStream.html, onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes)` See `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.OnDecodeTexturePngBytes)` above. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(kotlin.ByteArray,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)( input: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html, maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version, onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes? )` Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)( input: https://developer.android.com/reference/java/io/InputStream.html, maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version, onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes? )` Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,androidx.ink.storage.TexturePngBytesLookup)( brushFamily: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, textureIdToPngBytes: https://developer.android.com/reference/kotlin/androidx/ink/storage/TexturePngBytesLookup? )` Write a gzip-compressed serialized `ink.proto.BrushFamily` proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,java.io.OutputStream,androidx.ink.storage.TexturePngBytesLookup)( brushFamily: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, output: https://developer.android.com/reference/java/io/OutputStream.html, textureIdToPngBytes: https://developer.android.com/reference/kotlin/androidx/ink/storage/TexturePngBytesLookup? )` Write a gzip-compressed serialized `ink.proto.BrushFamily` proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. | android |

## Public functions

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun decode(input: ByteArray, onDecodeTexture: OnDecodeTexturePngBytes): BrushFamily
```

See `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(kotlin.ByteArray,androidx.ink.storage.OnDecodeTexturePngBytes)` above. This overload uses `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version#MAX_SUPPORTED()`.

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun decode(input: InputStream, onDecodeTexture: OnDecodeTexturePngBytes): BrushFamily
```

See `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.OnDecodeTexturePngBytes)` above. This overload uses `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version#MAX_SUPPORTED()`.

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun decode(
    input: ByteArray,
    maxVersion: Version = Version.MAX_SUPPORTED,
    onDecodeTexture: OnDecodeTexturePngBytes? = null
): BrushFamily
```

Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.brush.BrushFamily.Companion).decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)` instead.

| Parameters |
|---|---|
| `input: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` providing gzip-compressed `ink.proto.BrushFamily` binary proto messages, the same as written by `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,java.io.OutputStream,androidx.ink.storage.TexturePngBytesLookup)`. |
| `maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version = Version.MAX_SUPPORTED` | The maximum `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version` supported by the deserializer. Proto objects with a `min_version` of greater than maxVersion will be rejected. |
| `onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes? = null` | A callback to store any decoded texture image, if any were encoded inside the serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`s. This is called synchronously as part of this function call, on the same thread, once for each texture image. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` parsed from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(kotlin.ByteArray,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)` does not provide a valid `ink.proto.BrushFamily` proto message, or the corresponding `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` is invalid. |

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun decode(
    input: InputStream,
    maxVersion: Version = Version.MAX_SUPPORTED,
    onDecodeTexture: OnDecodeTexturePngBytes? = null
): BrushFamily
```

Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.brush.BrushFamily.Companion).decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)` instead.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/java/io/InputStream.html` | `https://developer.android.com/reference/java/io/InputStream.html` providing gzip-compressed `ink.proto.BrushFamily` binary proto messages, the same as written by `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,java.io.OutputStream,androidx.ink.storage.TexturePngBytesLookup)`. |
| `maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version = Version.MAX_SUPPORTED` | The maximum `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version` supported by the deserializer. Proto objects with a `min_version` of greater than maxVersion will be rejected. |
| `onDecodeTexture: https://developer.android.com/reference/kotlin/androidx/ink/storage/OnDecodeTexturePngBytes? = null` | A callback to store any decoded texture image, if any were encoded inside the serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`s. This is called synchronously as part of this function call, on the same thread, once for each texture image. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` parsed from the `https://developer.android.com/reference/java/io/InputStream.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if gzip-format bytes cannot be read from `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)` does not provide a valid `ink.proto.BrushFamily` proto message, or the corresponding `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` is invalid. |

### encode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun encode(
    brushFamily: BrushFamily,
    textureIdToPngBytes: TexturePngBytesLookup? = null
): ByteArray
```

Write a gzip-compressed serialized `ink.proto.BrushFamily` proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. If `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily#hasFallbacks()` is true, then the stored proto message including fallbacks for this `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` will be used instead of recomputing the proto from the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` object.

### encode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun encode(
    brushFamily: BrushFamily,
    output: OutputStream,
    textureIdToPngBytes: TexturePngBytesLookup? = null
): Unit
```

Write a gzip-compressed serialized `ink.proto.BrushFamily` proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. If `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily#hasFallbacks()` is true, then the stored proto message including fallbacks for this `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` will be used instead of recomputing the proto from the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` object.