samplePixels

fun ImageBitmap.samplePixels(sampleArea: Int = DEFAULT_SAMPLE_AREA): SampledPixels

Nearest-neighbour samples this bitmap down to at most sampleArea pixels.

Reads only the rows it keeps, so a 12 megapixel photo costs about 128 row reads and one 16k int array, never a full-size copy. Pass a sampleArea of zero or less to read every pixel.

Nearest neighbour is deliberate. Averaging would blend a vibrant pixel into the dull ones around it, and the vibrant pixels are the ones a theme wants.

Return

ARGB pixels in row-major order, plus the sampled width and height.

Parameters

sampleArea

The most pixels to keep, or zero and below to keep them all.