Пример #1
0
        public void DrawPixel(int x, int y)
        {
            if (x >= 0 && x < PictureResource.Width && y >= 0 && y < PictureResource.Height)
            {
                if (this.VisualEnabled)
                {
                    byte          color;
                    DitheredColor dithered = this.GraphicsRendererDriver.DitherColor(this.VisualColor);

                    if ((y & 1) == 0)
                    {
                        color = dithered.Even;
                    }
                    else
                    {
                        color = dithered.Odd;
                    }

                    this.Visual[(y * PictureResource.Width) + x] = color;
                }

                if (this.PriorityEnabled)
                {
                    this.Priority[(y * PictureResource.Width) + x] = this.PriorityColor;
                }
            }
        }
Пример #2
0
        public override void RenderSolidRectangle(PictureRectangle rect, byte color)
        {
            if (rect.X < 0 || rect.X > PictureResource.Width ||
                rect.Y < 0 || rect.Y > PictureResource.Height ||
                rect.Width < 0 || rect.Height < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(rect));
            }

            DitheredColor dithered = this.DitherColor(color);

            if ((rect.Width & 1) != 0)
            {
                for (int j = rect.Y - rect.Height + 1; j <= rect.Y; j++)
                {
                    int i = rect.X * 2;

                    this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2));
                    this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3));

                    for (int count = 0; count < ((rect.Width - 1) / 2); count++)
                    {
                        this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Even & 0xc) >> 2));
                        this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Even & 0x3));
                        this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2));
                        this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3));
                    }
                }
            }
            else
            {
                for (int j = rect.Y - rect.Height + 1; j <= rect.Y; j++)
                {
                    int i = rect.X * 2;

                    for (int count = 0; count < (rect.Width / 2); count++)
                    {
                        this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Even & 0xc) >> 2));
                        this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Even & 0x3));
                        this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2));
                        this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3));
                    }
                }
            }
        }