/// <summary> /// Constructs a controller that uses a 32-bit colour ARGB image specified by the provided pixel data. /// </summary> /// <param name="colorPixelData">The 32-bit colour ARGB pixel data.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="colorPixelData"/> is NULL.</exception> public FlashOverlayController(ColorPixelData colorPixelData) : this() { Platform.CheckForNullReference(colorPixelData, "colorPixelData"); _pixelData = colorPixelData.Raw; _rows = colorPixelData.Rows; _columns = colorPixelData.Columns; }
public void SetPixelARGB() { int rows = 19; int columns = 7; int bitsAllocated = 8; int samplesPerPixel = 4; int imageSize = rows * columns * bitsAllocated / 8 * samplesPerPixel; byte[] pixelData = new byte[imageSize]; ColorPixelData pixelDataWrapper = new ColorPixelData( rows, columns, pixelData); int x = 3; int y = 4; Color testValue = Color.FromArgb(10, 20, 30); pixelDataWrapper.SetPixel(x, y, testValue); Color actualValue = pixelDataWrapper.GetPixelAsColor(x, y); Assert.AreEqual(testValue, actualValue); pixelDataWrapper.SetPixel(x, y, testValue.ToArgb()); actualValue = pixelDataWrapper.GetPixelAsColor(x, y); Assert.AreEqual(testValue, actualValue); pixelDataWrapper.SetPixel(x, y, testValue.ToArgb()); actualValue = Color.FromArgb(pixelDataWrapper.GetPixel(x, y)); Assert.AreEqual(testValue, actualValue); // Make sure it works with unsafe code too fixed (byte* pPixelData = pixelDataWrapper.Raw) { int bytesPerPixel = 4; int stride = columns * bytesPerPixel; int i = (y * stride) + (x * bytesPerPixel); actualValue = Color.FromArgb(pPixelData[i + 2], pixelData[i + 1], pixelData[i]); } Assert.AreEqual(testValue, actualValue); }
/// <summary> /// Constructs a controller that uses a 32-bit colour ARGB image specified by the provided pixel data. /// </summary> /// <param name="colorPixelData">The 32-bit colour ARGB pixel data.</param> public FlashOverlayController(ColorPixelData colorPixelData) : this() { _pixelData = colorPixelData.Raw; _rows = colorPixelData.Rows; _columns = colorPixelData.Columns; }