コード例 #1
0
        protected void DisplayJPG(int x, int y)
        {
            var jpgData = LoadResource("meadow2.jpg");
            var decoder = new JpegDecoder();
            var jpg     = decoder.DecodeJpeg(jpgData);

            int  imageX = 0;
            int  imageY = 0;
            byte r, g, b;

            for (int i = 0; i < jpg.Length; i += 3)
            {
                r = jpg[i];
                g = jpg[i + 1];
                b = jpg[i + 2];

                Graphics.DrawPixel(imageX + x, imageY + y, Color.FromRgb(r, g, b));

                imageX++;
                if (imageX % decoder.Width == 0)
                {
                    imageY++;
                    imageX = 0;
                }
            }

            Display.Show();
        }
コード例 #2
0
        protected void Render()
        {
            lock (RenderLock)
            {
                if (IsRendering)
                {
                    Console.WriteLine("Already in render loop");
                    return;
                }

                IsRendering = true;
            }

            Graphics.Clear(false);

            Graphics.Stroke = 1;

            Graphics.DrawRectangle(
                x: 0, y: 0,
                width: (int)Display.Width - 10,
                height: (int)Display.Height - 10,
                Color.White);

            Graphics.DrawCircle(
                centerX: (int)Display.Width / 2 - 5,
                centerY: (int)Display.Height / 2 - 5,
                radius: (int)(Display.Width / 2) - 10,
                Color.FromHex("#23abe3"),
                filled: true);

            DisplayJPG(55, 40);

            string text = $"{Conditions.Temperature?.ToString("##.#")}°C";

            Graphics.CurrentFont = new Font12x20();
            Graphics.DrawText(
                x: (int)(Display.Width - text.Length * 24) / 2,
                y: 140,
                text: text,
                color: Color.Black,
                scaleFactor: GraphicsLibrary.ScaleFactor.X2);

            Graphics.Rotation = GraphicsLibrary.RotationType._180Degrees;

            Graphics.Show();

            IsRendering = false;
        }