-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathBitmapImageNeo3RGB.cs
34 lines (31 loc) · 1.35 KB
/
BitmapImageNeo3RGB.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
namespace Iot.Device.Ws28xx
{
/// <summary>
/// Special 24bit RGB format for Neo pixel LEDs where each bit is converted to 3 bits.
/// A one is converted to 110, a zero is converted to 100.
/// </summary>
/// <seealso cref="Iot.Device.Ws28xx.BitmapImageNeo3" />
internal class BitmapImageNeo3Rgb : BitmapImageNeo3
{
public BitmapImageNeo3Rgb(int width, int height)
: base(width, height)
{
}
public override void SetPixel(int x, int y, Color c)
{
var offset = (y * Stride) + (x * BytesPerPixel);
Data[offset++] = Lookup[(c.R * BytesPerComponent) + 0];
Data[offset++] = Lookup[(c.R * BytesPerComponent) + 1];
Data[offset++] = Lookup[(c.R * BytesPerComponent) + 2];
Data[offset++] = Lookup[(c.G * BytesPerComponent) + 0];
Data[offset++] = Lookup[(c.G * BytesPerComponent) + 1];
Data[offset++] = Lookup[(c.G * BytesPerComponent) + 2];
Data[offset++] = Lookup[(c.B * BytesPerComponent) + 0];
Data[offset++] = Lookup[(c.B * BytesPerComponent) + 1];
Data[offset++] = Lookup[(c.B * BytesPerComponent) + 2];
}
}
}