# ImageSelection

Artifact: [androidx.pdf:pdf-core](https://developer.android.com/jetpack/androidx/releases/pdf) [View Source](https://cs.android.com/search?q=file:androidx/pdf/selection/model/ImageSelection.kt+class:androidx.pdf.selection.model.ImageSelection) Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

*** ** * ** ***


```
class ImageSelection : Selection, AutoCloseable
```

<br />

*** ** * ** ***

Represents a specific image object selected from a PDF document.

The `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection` is delivered to the application if `PdfView.isImageSelectionEnabled` is enabled, via the `PdfView.OnSelectionChangedListener`. It can then be used to implement features like image sharing or copying. The `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#bounds()` can be passed to `PdfView.setHighlight` to visually highlight the selected image, while the `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#bitmap()` can be used for copying or sharing.

##### Memory Management

As this class holds a `https://developer.android.com/reference/android/graphics/Bitmap.html`, it implements `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-auto-closeable/index.html`. It is **mandatory** to call `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#close()` when the object is no longer needed to recycle the bitmap and avoid memory leaks. Using a `try-with-resources` statement (or the `use` extension function in Kotlin) is recommended for safe handling.

## Summary

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#close()()` |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#hashCode()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#bitmap()` This object captures the entire `https://developer.android.com/reference/android/graphics/Bitmap.html` of image located at the top of the Z-axis (the visually topmost image) at the interaction point. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/pdf/PdfRect>` | `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#bounds()` A list containing a single `https://developer.android.com/reference/kotlin/androidx/pdf/PdfRect` that defines the page number and the bounding box of the image in PDF points. |

## Public functions

### close

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
open fun close(): Unit
```

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

## Public properties

### bitmap

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
val bitmap: Bitmap
```

This object captures the entire `https://developer.android.com/reference/android/graphics/Bitmap.html` of image located at the top of the Z-axis (the visually topmost image) at the interaction point. This is the raw image data and not a "flattened" screenshot; the `https://developer.android.com/reference/kotlin/androidx/pdf/selection/model/ImageSelection#bitmap()` contains only the data for that specific image object and excludes overlapping text, vector graphics, or background content.

### bounds

```
open val bounds: List<PdfRect>
```

A list containing a single `https://developer.android.com/reference/kotlin/androidx/pdf/PdfRect` that defines the page number and the bounding box of the image in PDF points. These bounds represent the image's layout position and scale on the page.