|
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace ImagePixelEnumerator.Helpers.Pixels.NonIndexed
{
/// <summary>
/// Name | Blue | Green | Red | Alpha |
/// Bit |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
/// Byte |00000000000000000000000|11111111111111111111111|22222222222222222222222|33333333333333333333333|
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 4)]
public struct PixelDataArgb8888 : INonIndexedPixel
{
// raw component values
[FieldOffset(0)] private readonly Byte blue; // 00 - 07
[FieldOffset(1)] private readonly Byte green; // 08 - 15
[FieldOffset(2)] private readonly Byte red; // 16 - 23
[FieldOffset(3)] private readonly Byte alpha; // 24 - 31
// raw high-level values
[FieldOffset(0)] private Int32 raw; // 00 - 31
// processed component values
public Int32 Alpha { get { return alpha; } }
public Int32 Red { get { return red; } }
public Int32 Green { get { return green; } }
public Int32 Blue { get { return blue; } }
/// <summary>
/// See <see cref="INonIndexedPixel.Argb"/> for more details.
/// </summary>
public Int32 Argb
{
get { return raw; }
}
/// <summary>
/// See <see cref="INonIndexedPixel.GetColor"/> for more details.
/// </summary>
public Color GetColor()
{
return Color.FromArgb(Argb);
}
/// <summary>
/// See <see cref="INonIndexedPixel.SetColor"/> for more details.
/// </summary>
public void SetColor(Color color)
{
raw = color.ToArgb();
}
/// <summary>
/// See <see cref="INonIndexedPixel.Value"/> for more details.
/// </summary>
public UInt64 Value
{
get { return (UInt32) raw; }
set { raw = (Int32) (value & 0xFFFFFFFF); }
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.