Beispiel #1
0
        public static OutputPixel Decode(this ColorFormat colorFormat, uint value)
        {
            var outputPixel = default(OutputPixel);

            colorFormat.Decode(value, out outputPixel.R, out outputPixel.G, out outputPixel.B, out outputPixel.A);
            return(outputPixel);
        }
Beispiel #2
0
        public void TestStandardConformity()
        {
            var color = Color.FromArgb(0x12, 0x34, 0x56, 0x78);//ARGB
            var cf    = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);

            Assert.AreEqual(color.ToArgb(), cf.Decode(color.ToArgb()));
            Assert.AreEqual(0x34, (color.ToArgb() >> 16) & 0xff);
            Assert.AreEqual(0x12, (color.ToArgb() >> 24) & 0xff);
        }
Beispiel #3
0
        public int GetARGB(byte[] data, int offset, int x, int y)
        {
            int loffset = offset + (y * LineStride);
            int v;

            v = GetValue(data, loffset, x);
            v = ColorFormat.Decode(v);
            return(v);
        }
Beispiel #4
0
 public void TestDecode()
 {
     unchecked {
         var cf = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
         var result = cf.Decode((int)0x87654321);
         Assert.AreEqual((int)0x87654321, result);
         Assert.AreEqual((int)0x87, ((result >> 24) & 0xff));
     }
     {
         var cf = new ColorFormat(8, 4, 4, 4, 0, 4, 0, 0);
         var result = cf.Decode(0x0352);
         Assert.AreEqual((uint)0xff335522, (uint)result);
     }
 }
Beispiel #5
0
 public void TestDecode()
 {
     unchecked {
         var cf     = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
         var result = cf.Decode((int)0x87654321);
         Assert.AreEqual((int)0x87654321, result);
         Assert.AreEqual((int)0x87, ((result >> 24) & 0xff));
     }
     {
         var cf     = new ColorFormat(8, 4, 4, 4, 0, 4, 0, 0);
         var result = cf.Decode(0x0352);
         Assert.AreEqual((uint)0xff335522, (uint)result);
     }
 }
Beispiel #6
0
        public OutputPixel GetPixel(int x, int y)
        {
            if (!IsValidPosition(x, y))
            {
                return(new OutputPixel());
            }
            uint value;
            var  position = GetOffset(x, y);

            switch (BitsPerPixel)
            {
            case 16:
                value = *(ushort *)(Address + position);
                break;

            case 32:
                value = *(uint *)(Address + position);
                break;

            default: throw (new NotImplementedException());
            }
            //var OutputPixel = default(OutputPixel);
            return(ColorFormat.Decode(value));
        }
Beispiel #7
0
 public void TestStandardConformity()
 {
     var color = Color.FromArgb(0x12, 0x34, 0x56, 0x78);//ARGB
     var cf = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
     Assert.AreEqual(color.ToArgb(), cf.Decode(color.ToArgb()));
     Assert.AreEqual(0x34, (color.ToArgb() >> 16) & 0xff);
     Assert.AreEqual(0x12, (color.ToArgb() >> 24) & 0xff);
 }