Ejemplo n.º 1
0
        public override void DrawPrimitive(LGuiRect Rect, LGuiVec2[] Vertices, LGuiColor[] Colors, int[] Indices)
        {
            unsafe
            {
                var Texture = new Bitmap((int)Rect.Width, (int)Rect.Height, PixelFormat.Format32bppArgb);
                var Buffer  = Texture.LockBits(new Rectangle(0, 0, Texture.Width, Texture.Height), ImageLockMode.ReadWrite, Texture.PixelFormat);
                var Pointer = (byte *)Buffer.Scan0;

                for (var Index = 0; Index < Indices.Length; Index += 2)
                {
                    var X     = (int)Vertices[Indices[Index]].X;
                    var Y     = (int)Vertices[Indices[Index]].Y;
                    var Color = ColorCache.GetOrCreate(Colors[Indices[Index + 1]]);

                    var BufferIndex = Y * Buffer.Stride + X * 4;
                    Pointer[BufferIndex + 0] = Color.B;
                    Pointer[BufferIndex + 1] = Color.G;
                    Pointer[BufferIndex + 2] = Color.R;
                    Pointer[BufferIndex + 3] = Color.A;
                }

                Texture.UnlockBits(Buffer);

                Device_.DrawImage(Texture,
                                  new RectangleF(Rect.X, Rect.Y, Rect.Width, Rect.Height),
                                  new Rectangle(0, 0, Texture.Width, Texture.Height),
                                  GraphicsUnit.Pixel);
            }
        }
Ejemplo n.º 2
0
        internal static Brush GetOrCreate(LGuiColor GuiColor)
        {
            var Hash = GuiColor.GetHashCode();

            if (!BrushCache_.ContainsKey(Hash))
            {
                BrushCache_.Add(Hash, new SolidBrush(ColorCache.GetOrCreate(GuiColor)));
            }

            return(BrushCache_[Hash]);
        }
Ejemplo n.º 3
0
        internal static Pen GetOrCreate(LGuiColor GuiColor)
        {
            var Hash = GuiColor.GetHashCode();

            if (!PenCache_.ContainsKey(Hash))
            {
                PenCache_.Add(Hash, new Pen(ColorCache.GetOrCreate(GuiColor)));
            }

            return(PenCache_[Hash]);
        }