pixel-utils
Version:
Utility Functions for Pixels
8 lines (6 loc) • 544 B
text/typescript
import type { NO_DATA_VALUE, RawNoDataValue, RawPixel, CleanRGBA, ScaleFunction } from "../types";
export default function convert_raw_two_band_pixel_to_rgba(old_no_data_value: RawNoDataValue, new_no_data_value: NO_DATA_VALUE, scalefn1: ScaleFunction, scalefn2: ScaleFunction, pixel: RawPixel): CleanRGBA {
const [r, g] = pixel;
// @ts-ignore
return [r === old_no_data_value ? new_no_data_value : scalefn1(r), g === old_no_data_value ? new_no_data_value : scalefn2(g), 0, r === old_no_data_value || g === old_no_data_value ? 0 : 255];
}