#706 fixed live histogram for animated items
This commit is contained in:
parent
27785c0db9
commit
1d13c09379
2 changed files with 5 additions and 3 deletions
|
@ -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 : {});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue