Skip to content

argbToRgb

Converts a 32-bit packed ARGB integer (as used by e.g. Chromium’s Local State profile background_color field) into a CSS rgb() string. The alpha byte (top 8 bits) is read but discarded — the result is always opaque.

Available since next

import { argbToRgb } from '@helpers4/color';
argbToRgb(argb: number): string
ParameterTypeDescription
argbnumberA 32-bit integer where bits 24-31 are alpha, 16-23 are red, 8-15 are green, and 0-7 are blue

string — A rgb(r,g,b) CSS color string

Convert a packed ARGB integer to a CSS color

Section titled “Convert a packed ARGB integer to a CSS color”

The top byte (alpha) is discarded — the result is always opaque.

argbToRgb(0xffff0000)
// => 'rgb(255,0,0)'

Two ARGB values differing only in the alpha byte produce the same rgb() string.

argbToRgb(0x00ff0000) === argbToRgb(0x80ff0000)
// => true

View source on GitHub