getBrightnessFrom method
This gets the brightness of any image (image as Uint8List
). The function returns
a brightness level between 0 and 255, where 0 = totally black and 255 = totally bright.
skipPixel
parameter refers to number of pixels to skip while calculating Wallpaper's brightness.
skipPixel
defaults to 1 (every pixel is counted) and can't be less than 1.
Note:
- This method needs the READ_EXTERNAL_STORAGE permission on Android Oreo & above.
Implementation
static getBrightnessFrom(Uint8List imageData, {int skipPixel = 1}) async {
assert(skipPixel > 0, 'skipPixel should have a value greater than 0');
assert(imageData != null, 'imageData should not be null');
int data = await _channel.invokeMethod(
'getBrightnessFrom', {'skipPixel': skipPixel, "imageData": imageData});
return data;
}