/
deemas-077
/
proba
Обзор
Документация
Войти
/
deemas-077
/
proba
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
BitmapMaker.cs
77 строк
3 KB
deemas-077
Create: .gitignore, BitmapMaker.cs, BundleGenerator.cs, CompanionResourceDllGenerator.cs, CuixBuilder.csproj, CuixConfig.cs, CuixGenerator.cs, CuiXml.cs, LICENSE, Program.cs, README.md
08 авг 2026, 06:30
Верифицирован
08 авг 2026, 06:30
53dbcfc
Код
Авторство
О чём код?
static class BitmapMaker { // 8-color palette — one per button slot (cycles when > 8 buttons) public static readonly (byte R, byte G, byte B)[] Palette = [ (0x00, 0x78, 0xD7), // blue (0x10, 0x7C, 0x10), // green (0xD8, 0x3B, 0x01), // orange (0x87, 0x64, 0xB8), // purple (0x00, 0x82, 0x72), // teal (0xE8, 0x11, 0x23), // red (0xFF, 0xB9, 0x00), // amber (0x00, 0xB7, 0xC3), // cyan ]; public static byte[] Make16x16((byte R, byte G, byte B) color) => Make16x16(color.R, color.G, color.B); // 16x16 24-bit BMP: colored background, white cross, black border public static byte[] Make16x16(byte r, byte g, byte b) { const int width = 16, height = 16, bpp = 3; int rowSize = width * bpp; // 48 — already DWORD-aligned int pixelBytes = rowSize * height; // 768 int fileSize = 14 + 40 + pixelBytes; // 822 var buf = new byte[fileSize]; int p = 0; // BITMAPFILEHEADER buf[p++] = 0x42; buf[p++] = 0x4D; WriteI32(buf, ref p, fileSize); WriteI16(buf, ref p, 0); WriteI16(buf, ref p, 0); WriteI32(buf, ref p, 54); // BITMAPINFOHEADER WriteI32(buf, ref p, 40); WriteI32(buf, ref p, width); WriteI32(buf, ref p, height); WriteI16(buf, ref p, 1); WriteI16(buf, ref p, 24); WriteI32(buf, ref p, 0); WriteI32(buf, ref p, 0); WriteI32(buf, ref p, 0); WriteI32(buf, ref p, 0); WriteI32(buf, ref p, 0); WriteI32(buf, ref p, 0); // Pixel data — bottom-up, BGR order for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { bool border = x == 0 || x == 15 || y == 0 || y == 15; bool cross = x == 7 || x == 8 || y == 7 || y == 8; if (border) { buf[p++] = 0x00; buf[p++] = 0x00; buf[p++] = 0x00; } else if (cross) { buf[p++] = 0xFF; buf[p++] = 0xFF; buf[p++] = 0xFF; } else { buf[p++] = b; buf[p++] = g; buf[p++] = r; } } return buf; } static void WriteI32(byte[] buf, ref int p, int v) { buf[p++] = (byte)( v & 0xFF); buf[p++] = (byte)((v >> 8) & 0xFF); buf[p++] = (byte)((v >> 16) & 0xFF); buf[p++] = (byte)((v >> 24) & 0xFF); } static void WriteI16(byte[] buf, ref int p, short v) { buf[p++] = (byte)( v & 0xFF); buf[p++] = (byte)((v >> 8) & 0xFF); } }