Exemple #1
0
        private XMPixel ConvertPixel(Color source, int mode)
        {
            var pixel = new XMPixel(0, 0);
            int value = 0;

            switch (mode)
            {
            case 0:
                value = (source.R + source.G + source.B) / 3;
                pixel = new XMPixel(1, (byte)value);
                break;

            case 1:
                value = (source.R) / 12;
                pixel = new XMPixel(1, (byte)value);
                break;

            case 2:
                value = (source.R) / 12;
                pixel = new XMPixel(2, (byte)value);
                break;

            default:
                throw new Exception(string.Format("Invalid pixel mode: {0}", mode));
            }

            return(pixel);
        }
Exemple #2
0
        public void Plot(int x, int y, XMPixel pixel)
        {
            // boundary check
            var channelCount = UnpackedPatternData.Length / 5 / RowCount;

            if (x < 0)
            {
                return;
            }
            if (y < 0)
            {
                return;
            }
            if (x > channelCount)
            {
                return;
            }
            if (y >= RowCount)
            {
                return;
            }

            UnpackedPatternData[(x * 5) + (y * channelCount * 5) + pixel.Column] = pixel.Value;
        }