LuminanceSourceAbstract
in package
implements
LuminanceSourceInterface
The purpose of this class hierarchy is to abstract different bitmap implementations across platforms into a standard interface for requesting greyscale luminance values. The interface only provides immutable methods; therefore crop and rotation create copies. This is to ensure that one Reader does not modify the original luminance source and leave it in an unknown state for other Readers in the chain.
Tags
Interfaces, Classes, Traits and Enums
Table of Contents
- $height : int
- $luminances : array<string|int, mixed>
- $options : SettingsContainerInterface
- $width : int
- __construct() : mixed
- getHeight() : int
- getLuminances() : array<string|int, mixed>
- Fetches luminance data for the underlying bitmap. Values should be fetched using: `int luminance = array[y * width + x] & 0xff`
- getRow() : array<string|int, mixed>
- Fetches one row of luminance data from the underlying platform's bitmap. Values range from 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have to bitwise and with 0xff for each value. It is preferable for implementations of this method to only fetch this row rather than the whole image, since no 2D Readers may be installed and getLuminances() may never be called.
- getWidth() : int
- checkFile() : string
- setLuminancePixel() : void
Properties
$height
protected
int
$height
$luminances
protected
array<string|int, mixed>
$luminances
$options
protected
SettingsContainerInterface
$options
$width
protected
int
$width
Methods
__construct()
public
__construct(int $width, int $height[, SettingsContainerInterface $options = null ]) : mixed
Parameters
- $width : int
- $height : int
- $options : SettingsContainerInterface = null
Return values
mixed —getHeight()
public
getHeight() : int
Tags
Return values
int —The height of the bitmap.
getLuminances()
Fetches luminance data for the underlying bitmap. Values should be fetched using: `int luminance = array[y * width + x] & 0xff`
public
getLuminances() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —A row-major 2D array of luminance values. Do not use result.length as it may be larger than width * height bytes on some platforms. Do not modify the contents of the result.
getRow()
Fetches one row of luminance data from the underlying platform's bitmap. Values range from 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have to bitwise and with 0xff for each value. It is preferable for implementations of this method to only fetch this row rather than the whole image, since no 2D Readers may be installed and getLuminances() may never be called.
public
getRow(int $y) : array<string|int, mixed>
Parameters
- $y : int
-
The row to fetch, which must be in [0,getHeight())
Tags
Return values
array<string|int, mixed> —An array containing the luminance data.
getWidth()
public
getWidth() : int
Tags
Return values
int —The width of the bitmap.
checkFile()
protected
static checkFile(string $path) : string
Parameters
- $path : string
Tags
Return values
string —setLuminancePixel()
protected
setLuminancePixel(int $r, int $g, int $b) : void
Parameters
- $r : int
- $g : int
- $b : int