ScanOrientation Enumeration

enum ScanOrientation : Enum<ScanOrientation>

Which way up an image is, using the same eight cases as the EXIF orientation tag.

A photographed page carries its orientation as metadata rather than in its pixels, so a picture can be stored sideways and displayed upright. ScanPicture.orientation reports what the SDK believes a page’s orientation to be, and setting it changes that belief without rewriting the pixels.

Reading the diagrams. Each case below carries a small picture drawn out of block characters. It is the capital letter F, and it shows how that letter would look in an image stored with this orientation. Compare any of them with the upright F under Normal: the difference between the two is exactly the transformation the case describes.

██████        ██████              ██
██                ██              ██
████            ████            ████
██                ██              ██
██                ██          ██████
Normal        FlipHorizontal   Rotate180

F is a common illustration for this rather than anything the EXIF standard prescribes — the specification itself defines the cases as coordinate mappings. The letter earns its place because it looks different under every rotation and every mirroring: an O, H or X would come out identical under several of the eight, so a diagram using one could not tell you which had been applied. F has no symmetry at all, so every case is distinguishable at a glance.

Entries

Undefined

Undefined

No orientation is known, so the image is displayed exactly as stored.

Normal

Normal

Upright: the image displays exactly as stored.

FlipHorizontal

FlipHorizontal

Mirrored left to right, the right way up.

Rotate180

Rotate180

Upside down, a half turn from upright.

FlipVertical

FlipVertical

Mirrored top to bottom.

Transpose

Transpose

Mirrored across the leading diagonal: rotated a quarter turn and flipped.

Rotate90

Rotate90

Rotated a quarter turn clockwise.

Transverse

Transverse

Mirrored across the trailing diagonal: rotated a quarter turn the other way and flipped.

Rotate270

Rotate270

Rotated a quarter turn anticlockwise.

Invalid

Invalid

Not a real orientation: a sentinel for a value that was never set.

Types

Companion

object Companion

Conversions between an orientation and its stored integer form.

Properties

entries

val entries: EnumEntries<ScanOrientation>

Returns a representation of an immutable list of all enum entries, in the order they’re declared.

name

val name: String

ordinal

val ordinal: Int

Functions

areDimensionsSwapped

fun areDimensionsSwapped(): Boolean

Whether this orientation exchanges the image’s width and height.

ensure

fun ensure(default: ScanOrientation = Normal): ScanOrientation

Returns this orientation, or default when it is unset or invalid.

isDefined

fun isDefined(): Boolean

Whether an orientation is actually known, as opposed to unset or invalid.

isDisplay

fun isDisplay(): Boolean

Whether the image can be displayed as stored, needing no rotation.

isValid

fun isValid(): Boolean

Whether this is a real orientation rather than the Invalid sentinel.

orUndefined

fun ScanOrientation?.orUndefined(): ScanOrientation

Returns this orientation, or ScanOrientation.Undefined when it is null.

rotate180dg

fun rotate180dg(): ScanOrientation

Returns this orientation turned a half turn.

rotateCCW

fun rotateCCW(): ScanOrientation

Returns this orientation turned a quarter turn anticlockwise.

rotateCW

fun rotateCW(): ScanOrientation

Returns this orientation turned a quarter turn clockwise.

toInt

fun toInt(): Int

Returns the EXIF integer this orientation corresponds to.

valueOf

fun valueOf(value: String): ScanOrientation

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

values

fun values(): Array<ScanOrientation>

Returns an array containing the constants of this enum type, in the order they’re declared.

Top