Fix #12 (#15)
Some checks failed
Build TinkeDSi nightly x86 / build (push) Has been cancelled
Build TinkeDSi nightly / build (push) Has been cancelled
Build TinkeDSi nightly with mono / build (push) Has been cancelled

This commit is contained in:
SombrAbsol 2025-06-16 01:18:54 +00:00 committed by GitHub
parent 94dcf781da
commit 7a82f5ed55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,9 +88,10 @@ namespace Ekona.Images
/// <returns>Colors</returns> /// <returns>Colors</returns>
public static Color[] BGR555ToColor(byte[] bytes) public static Color[] BGR555ToColor(byte[] bytes)
{ {
Color[] colors = new Color[bytes.Length / 2]; int colorCount = bytes.Length / 2;
Color[] colors = new Color[colorCount];
for (int i = 0; i < bytes.Length / 2; i++) for (int i = 0; i < colorCount; i++)
colors[i] = BGR555ToColor(bytes[i * 2], bytes[i * 2 + 1]); colors[i] = BGR555ToColor(bytes[i * 2], bytes[i * 2 + 1]);
return colors; return colors;
@ -100,12 +101,15 @@ namespace Ekona.Images
/// </summary> /// </summary>
public static Color BGR555ToColor(byte byte1, byte byte2) public static Color BGR555ToColor(byte byte1, byte byte2)
{ {
int r, b, g; int bgr = byte1 | (byte2 << 8);
short bgr = BitConverter.ToInt16(new Byte[] { byte1, byte2 }, 0);
r = (bgr & 0x001F) * 0x08; int r5 = bgr & 0x1F;
g = ((bgr & 0x03E0) >> 5) * 0x08; int g5 = (bgr >> 5) & 0x1F;
b = ((bgr & 0x7C00) >> 10) * 0x08; int b5 = (bgr >> 10) & 0x1F;
int r = (r5 * 255) / 31;
int g = (g5 * 255) / 31;
int b = (b5 * 255) / 31;
return Color.FromArgb(r, g, b); return Color.FromArgb(r, g, b);
} }