Ejemplo n.º 1
0
        /// <summary>
        /// Draw a frame around the buffer from (0,0) to (width, height)
        /// </summary>
        void DrawFrame(PixelsBuffer buffer, Cross.Drawing.Color color)
        {
            int idx = 0; //pixel index

            //draw left, right lines
            for (int y = 0; y < buffer.Height; y++)
            {
                //left
                idx = buffer.StartOffset + buffer.Stride * y;// buffer.GetPixelIndex(0, y);
                buffer.Data[idx] = color.Data;

                //right
                idx = buffer.StartOffset + buffer.Stride * y + buffer.Width - 1;// buffer.GetPixelIndex(buffer.Width - 1, y);
                buffer.Data[idx] = color.Data;
            }

            //draw top, bottom lines
            for (int x = 0; x < buffer.Width; x++)
            {
                //top
                idx = buffer.StartOffset + x;// buffer.GetPixelIndex(x, 0);
                buffer.Data[idx] = color.Data;

                //bottom
                idx = buffer.StartOffset + (buffer.Height - 1) * buffer.Stride + x;// buffer.GetPixelIndex(x, buffer.Height - 1);
                buffer.Data[idx] = color.Data;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draw a diagonal line with the specified color from (0,0) to (width, height)
        /// </summary>
        void DrawLine(PixelsBuffer buffer, Cross.Drawing.Color color)
        {
            int idx = 0; //pixel index

            for (int i = 0; i < buffer.Height; i++)
            {
                idx = buffer.StartOffset + i * buffer.Stride + i; // buffer.GetPixelIndex(i, i);
                buffer.Data[idx] = color.Data;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new instance
 /// <para>Note: This constructor does not check whether values are within correct range [0, 255]</para>
 /// </summary>
 public Color(Color source, int alpha)
 {
     Data = source.Data | (uint)(alpha << 24);
     Precalculate();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new color from the original color but with different alpha
 /// </summary>
 /// <param name="orginal">The color to copy R, G, B component from</param>
 /// <param name="alpha">The new alpha component. Range: [0, 2555]</param>
 public static Color Create(Color orginal, byte alpha)
 {
     return new Color(orginal, alpha);
 }