#706 fixed live histogram for animated items

This commit is contained in:
Thibault Deckers 2023-08-17 00:17:58 +02:00
parent 27785c0db9
commit 1d13c09379
2 changed files with 5 additions and 3 deletions

View file

@ -78,7 +78,8 @@ class _ImageHistogramState extends State<ImageHistogram> {
Future<void> _updateLevels(ImageInfo info) async {
final targetEntry = entry;
final newLevels = await viewStateController.getHistogramLevels(info);
final forceUpdate = targetEntry.isAnimated;
final newLevels = await viewStateController.getHistogramLevels(info, forceUpdate);
if (mounted) {
setState(() => _levels = targetEntry == entry ? newLevels : {});
}

View file

@ -18,8 +18,8 @@ mixin HistogramMixin {
static const int bins = 256;
static const int normMax = bins - 1;
Future<HistogramLevels> getHistogramLevels(ImageInfo info) async {
if (_levels.isEmpty) {
Future<HistogramLevels> getHistogramLevels(ImageInfo info, bool forceUpdate) async {
if (_levels.isEmpty || forceUpdate) {
if (_completer == null) {
_completer = Completer();
final data = (await info.image.toByteData(format: ImageByteFormat.rawExtendedRgba128))!;
@ -31,6 +31,7 @@ mixin HistogramMixin {
_completer?.complete();
} else {
await _completer?.future;
_completer = null;
}
}
return _levels;