Skip to content

Commit

Permalink
Optimize the library (feat. @Scighost)
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jun 3, 2023
1 parent b446c00 commit 05ad2db
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 263 deletions.
11 changes: 5 additions & 6 deletions ColorThief/Class/CMap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Drawing;

namespace ColorThiefDotNet
{
Expand Down Expand Up @@ -26,8 +27,8 @@ public IEnumerable<QuantizedColor> GeneratePalette()
{
foreach (VBox vbox in vboxes)
{
int[] rgb = vbox.Avg(false);
CTColor color = FromRgb(rgb[0], rgb[1], rgb[2]);
int rgb = vbox.Avg(false);
Color color = Color.FromArgb((byte)(rgb >> 16 & 0xFF), (byte)(rgb >> 8 & 0xFF), (byte)(rgb >> 0 & 0xFF));
yield return new QuantizedColor(color, vbox.Count(false));
}
}
Expand All @@ -39,15 +40,13 @@ public List<QuantizedColor> GeneratePaletteList()
palette = new List<QuantizedColor>();
foreach (VBox vbox in vboxes)
{
int[] rgb = vbox.Avg(false);
CTColor color = FromRgb(rgb[0], rgb[1], rgb[2]);
int rgb = vbox.Avg(false);
Color color = Color.FromArgb((byte)(rgb >> 16 & 0xFF), (byte)(rgb >> 8 & 0xFF), (byte)(rgb >> 0 & 0xFF));
palette.Add(new QuantizedColor(color, vbox.Count(false)));
}
}

return palette;
}

public CTColor FromRgb(int red, int green, int blue) => new CTColor { R = (byte)red, G = (byte)green, B = (byte)blue };
}
}
23 changes: 0 additions & 23 deletions ColorThief/Class/Color.cs

This file was deleted.

81 changes: 0 additions & 81 deletions ColorThief/Class/ColorThief.cs

This file was deleted.

Loading

0 comments on commit 05ad2db

Please sign in to comment.