# Image

## Content

# Class: Image

Represents a JPEG or PNG image instance.

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### height

#### Get Signature

```ts
get height(): number;
```

Gets the height of the image, in pixels.

##### Returns

`number`

***

### id

#### Get Signature

```ts
get id(): number;
```

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### om

#### Get Signature

```ts
get om(): ObjectManager;
```

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

***

### opaque

#### Get Signature

```ts
get opaque(): boolean;
```

Gets the value indicating if the image is opaque.

##### Returns

`boolean`

***

### type

#### Get Signature

```ts
get type(): ImageType;
```

Gets the type of the image, such as JPEG or PNG.

##### Returns

[`ImageType`](../enumerations/ImageType)

***

### width

#### Get Signature

```ts
get width(): number;
```

Gets the width of the image, in pixels.

##### Returns

`number`

## Methods

### load()

#### Call Signature

```ts
static load(imageBytes): Image;
```

Creates an Image from the byte array with JPEG or PNG encoded image data.

##### Parameters

###### imageBytes

`Uint8Array`

The binary data of the image.

##### Returns

`Image`

A new instance of the Image.

#### Call Signature

```ts
static load(om, imageBytes): Image;
```

Creates an Image from the byte array with JPEG or PNG encoded image data.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Image object.

###### imageBytes

`Uint8Array`

The binary data of the image.

##### Returns

`Image`

A new instance of the Image.

***

### free()

```ts
free(): void;
```

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### rebind()

```ts
rebind(omTo): void;
```

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### save()

```ts
save(): Uint8Array;
```

Saves the Image as a byte array with PNG or JPEG-encoded image data.

#### Returns

`Uint8Array`

A byte array with image data.

***

### toBitmap()

```ts
toBitmap(): Bitmap;
```

Creates a [Bitmap](Bitmap) instance from the current Image.

#### Returns

[`Bitmap`](Bitmap)

A new instance of [Bitmap](Bitmap) with image data.
