Exemplo n.º 1
0
        public void TestGetRGBADataAt()
        {
            BitmapData bitmapData = new BitmapData();

            bitmapData.Data = new byte[] {
                33, 255, 29, 8, 40, 82, 39, 88, 12, 0, 0, 0,
                28, 128, 37, 200, 182, 22, 47, 19, 192, 0, 0, 0,
                89, 45, 221, 120, 23, 64, 11, 33, 191, 0, 0, 0
            };
            bitmapData.ColorMode = BitmapColorMode.RGBA;
            bitmapData.Width     = 3;
            bitmapData.Height    = 3;
            Assert.Equal(new RGBA(8, 29, 255, 33), bitmapData.GetRGBADataAt(0, 0));
            Assert.Equal(new RGBA(0, 0, 0, 12), bitmapData.GetRGBADataAt(2, 0));
            Assert.Equal(new RGBA(0, 0, 0, 191), bitmapData.GetRGBADataAt(2, 2));
            Assert.Throws <ArgumentOutOfRangeException>(() => bitmapData.GetRGBADataAt(3, 1));
            Assert.Throws <NotThisColorModeException>(() => bitmapData.GetRGBDataAt(1, 0));
        }