pixel-data-js 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,7 @@ __export(src_exports, {
70
70
  fillPixelData: () => fillPixelData,
71
71
  floodFillSelection: () => floodFillSelection,
72
72
  getImageDataFromClipboard: () => getImageDataFromClipboard,
73
+ getIndexedImageColorCounts: () => getIndexedImageColorCounts,
73
74
  getSupportedPixelFormats: () => getSupportedPixelFormats,
74
75
  hardLightFast: () => hardLightFast,
75
76
  hardLightPerfect: () => hardLightPerfect,
@@ -1804,6 +1805,18 @@ function indexedImageToAverageColor(indexedImage, includeTransparent = false) {
1804
1805
  return packColor(r, g, b, a);
1805
1806
  }
1806
1807
 
1808
+ // src/IndexedImage/getIndexedImageColorCounts.ts
1809
+ function getIndexedImageColorCounts(indexedImage) {
1810
+ const data = indexedImage.data;
1811
+ const palette = indexedImage.palette;
1812
+ const frequencies = new Int32Array(palette.length);
1813
+ for (let i = 0; i < data.length; i++) {
1814
+ const colorIndex = data[i];
1815
+ frequencies[colorIndex]++;
1816
+ }
1817
+ return frequencies;
1818
+ }
1819
+
1807
1820
  // src/Input/fileInputChangeToImageData.ts
1808
1821
  async function fileInputChangeToImageData(event) {
1809
1822
  const target = event.target;
@@ -2522,6 +2535,7 @@ function rotateSquareInPlace(pixelData) {
2522
2535
  fillPixelData,
2523
2536
  floodFillSelection,
2524
2537
  getImageDataFromClipboard,
2538
+ getIndexedImageColorCounts,
2525
2539
  getSupportedPixelFormats,
2526
2540
  hardLightFast,
2527
2541
  hardLightPerfect,