# 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)

*** ** * ** ***


```
public final class ImageSelection implements Selection, AutoCloseable
```

<br />

*** ** * ** ***

Represents a specific image object selected from a PDF document.

The `https://developer.android.com/reference/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/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/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/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 methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/pdf/selection/model/ImageSelection#close()()` |
| `boolean` | `https://developer.android.com/reference/androidx/pdf/selection/model/ImageSelection#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/androidx/pdf/selection/model/ImageSelection#getBitmap()()` 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. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfRect>` | `https://developer.android.com/reference/androidx/pdf/selection/model/ImageSelection#getBounds()()` A list containing a single `https://developer.android.com/reference/androidx/pdf/PdfRect` that defines the page number and the bounding box of the image in PDF points. |
| `int` | `https://developer.android.com/reference/androidx/pdf/selection/model/ImageSelection#hashCode()()` |

## Public methods

### close

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

```
public void close()
```

### equals

```
public boolean equals(Object other)
```

### getBitmap

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

```
public final @NonNull Bitmap getBitmap()
```

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/androidx/pdf/selection/model/ImageSelection#bitmap()` contains only the data for that specific image object and excludes overlapping text, vector graphics, or background content.

### getBounds

```
public @NonNull List<@NonNull PdfRect> getBounds()
```

A list containing a single `https://developer.android.com/reference/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.

### hashCode

```
public int hashCode()
```