INNER CODE UNIT · TypeScript
sRGBToLinear
margelo/react-native-blurhash · src/utils.ts:18
function sRGBToLinear(value: number): number {
const v = value / 255;
if (v <= 0.04045) return v / 12.92;
else return Math.pow((v + 0.055) / 1.055, 2.4);
}
export function decodeDC(value: number): RGB {
const intR = value >> 16;
const intG = (value >> 8) & 255;
const intB = value & 255;
return { r: sRGBToLinear(intR) * 255, g: sRGBToLinear(intG) * 255, b: sRGBToLinear(intB) * 255 };
}
export function decode83(str: string): number {
let value = 0;
for (let i = 0; i < str.length; i++) {
const c = str[i];
const digit = digitCharacters.indexOf(c);