Skip to content

Commit

Permalink
Improve image color ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Dec 9, 2024
1 parent 05439d2 commit 6773a74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/src/utils/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,19 @@ class ImageColorWorker {
final QuantizerResult quantizerResult =
await QuantizerCelebi().quantize(
resized.buffer.asUint32List(),
128,
returnInputPixelToClusterPixel: true,
32,
);
final Map<int, int> colorToCount = quantizerResult.colorToCount.map(
(int key, int value) =>
MapEntry<int, int>(_getArgbFromAbgr(key), value),
);
// Score colors for color scheme suitability.
final List<int> scoredResults = Score.score(colorToCount, desired: 1);
final List<int> scoredResults = Score.score(
colorToCount,
desired: 1,
fallbackColorARGB: 0xFFEEEEEE,
filter: false,
);
final Hct sourceColor = Hct.fromInt(scoredResults.first);
final scheme = SchemeFidelity(
sourceColorHct: sourceColor,
Expand Down

0 comments on commit 6773a74

Please sign in to comment.