Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_LowLevel🞂Div255Function

Div255

Fast integer division by 255 for color channel calculations.

Declarations ​

pascal
function Div255(Value: Word): Word;
function FastDiv255(Value: Word): Word;
function Div255Round(Value: Word): Word;
Overload Details

Overload 1 ​

pascal
function Div255(Value: Word): Word;

Fast integer division by 255 for inputs in range [0..$FFFF].

ParameterTypeDescription
ValueWord16-bit word value to divide by 255 (valid for [0..65535]).
TypeDescription
WordResult of Value div 255.

Overload 2 ​

pascal
function FastDiv255(Value: Word): Word;

Ultra-fast integer division by 255 for inputs in range [0..255255].*

ParameterTypeDescription
ValueWord16-bit word value to divide by 255 (valid for [0..65025]).
TypeDescription
WordResult of Value div 255.

Overload 3 ​

pascal
function Div255Round(Value: Word): Word;

Fast rounded integer division by 255 for inputs in range [0..255255].*

ParameterTypeDescription
ValueWord16-bit word value to divide and round by 255 (valid for [0..65025]).
TypeDescription
WordRounded result of Round(Value / 255).

Description ​

Div255, FastDiv255, and Div255Round perform high-speed integer division by 255 without using expensive hardware division instructions. They use reciprocal multiplication and shift magic numbers, making them highly efficient for 8-bit channel blending and alpha scaling.

See also ​