Ejemplo n.º 1
0
            public override void DecodePixel(byte[] source, int sourceIndex, byte[] destination, int destinationIndex)
            {
                ushort pixel1 = BitConverter.ToUInt16(source, sourceIndex);
                ushort pixel2 = BitConverter.ToUInt16(source, sourceIndex + 2);

                int Y0 = (pixel1 & 0xFF00) >> 8, U = (pixel1 & 0x00FF);
                int Y1 = (pixel2 & 0xFF00) >> 8, V = (pixel2 & 0x00FF);

                byte r1 = MathExtensions.ClampByte((int)(Y0 + 1.375 * (V - 128)));
                byte g1 = MathExtensions.ClampByte((int)(Y0 - 0.6875 * (V - 128) - 0.34375 * (U - 128)));
                byte b1 = MathExtensions.ClampByte((int)(Y0 + 1.71875 * (U - 128)));

                byte r2 = MathExtensions.ClampByte((int)(Y1 + 1.375 * (V - 128)));
                byte g2 = MathExtensions.ClampByte((int)(Y1 - 0.6875 * (V - 128) - 0.34375 * (U - 128)));
                byte b2 = MathExtensions.ClampByte((int)(Y1 + 1.71875 * (U - 128)));

                destination[destinationIndex + 3] = 0xFF;
                destination[destinationIndex + 2] = r1;
                destination[destinationIndex + 1] = g1;
                destination[destinationIndex + 0] = b1;

                destination[destinationIndex + 4 + 3] = 0xFF;
                destination[destinationIndex + 4 + 2] = r2;
                destination[destinationIndex + 4 + 1] = g2;
                destination[destinationIndex + 4 + 0] = b2;
            }