Initial commit: application ColorPicker (palette, pipette ecran, couleur de dossier)

This commit is contained in:
Florian
2026-09-03 21:48:28 +02:00
commit 44c51398b8
13 changed files with 956 additions and 0 deletions

34
tests/IconPreview.cs Normal file
View File

@@ -0,0 +1,34 @@
using System.Drawing;
using System.IO;
namespace ColorPickerApp
{
internal static class IconPreview
{
private static void Main(string[] args)
{
string dir = Path.Combine(Path.GetTempPath(), "cp_preview");
Directory.CreateDirectory(dir);
FolderColorizer.ApplyColor(dir, Color.FromArgb(220, 40, 60));
byte[] icoBytes = File.ReadAllBytes(Path.Combine(dir, ".colorpicker_folder.ico"));
int count = System.BitConverter.ToUInt16(icoBytes, 4);
// trouver l'entree 256x256 (largeur stockee = 0) avec le plus grand bytesInRes
int bestOffset = -1, bestSize = -1, bestLen = 0;
for (int i = 0; i < count; i++)
{
int entryOffset = 6 + i * 16;
int w = icoBytes[entryOffset];
int len = System.BitConverter.ToInt32(icoBytes, entryOffset + 8);
int off = System.BitConverter.ToInt32(icoBytes, entryOffset + 12);
if (w == 0 && len > bestLen) { bestLen = len; bestOffset = off; bestSize = w; }
}
var pngBytes = new byte[bestLen];
System.Array.Copy(icoBytes, bestOffset, pngBytes, 0, bestLen);
File.WriteAllBytes(Path.Combine(Path.GetTempPath(), "cp_icon_preview.png"), pngBytes);
FolderColorizer.RestoreDefault(dir);
Directory.Delete(dir, true);
}
}
}