Skip to content

tmk907/PaletteNet

Repository files navigation

PaletteNet

Library to extract prominent colors from an image.

  • Dominant
  • Vibrant
  • Vibrant Dark
  • Vibrant Light
  • Muted
  • Muted Dark
  • Muted Light

.NET port of Android's Palette https://developer.android.com/reference/android/support/v7/graphics/Palette.html

Install

Nuget https://www.nuget.org/packages/PaletteNet

Target frameworks:

  • net6.0
  • net6.0-android
  • net6.0-windows10.0.19041.0
  • netstandard2.0
  • net48

Example (WinUI3)

using IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read);
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(fileStream);

PaletteColors palette = PaletteColors.Generate(new BitmapDecoderHelper(decoder));
Color dominantColor = palette.DominantColor;
IEnumerable<Color> allColors = palette.GetAllColors();

or

IBitmapHelper bitmapHelper = new BitmapDecoderHelper(decoder);
PaletteBuilder paletteBuilder = new PaletteBuilder();
Palette palette = paletteBuilder.Generate(bitmapHelper);
int? rgbColor = palette.MutedColor;
int? rgbTextColor = palette.DominantSwatch.TitleTextColor;

screenshot 1 screenshot 2

Sample app

Download app from Microsoft Store

English badge

Color palette icons created by Freepik - Flaticon

About

.NET port of Android's Palette. Extract prominent colors from an image

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages