Exemplo n.º 1
0
        /// <summary>
        /// Processes the bitmap.
        /// </summary>
        /// <param name="a">
        /// The bitmap.
        /// </param>
        /// <returns>
        /// The <see cref="BitmapCompare.RGBData"/> .
        /// </returns>
        private static RGBData ProcessBitmap(Bitmap a)
        {
            var bmpData = a.LockBits(
                new Rectangle(0, 0, a.Width, a.Height),
                ImageLockMode.ReadOnly,
                PixelFormat.Format24bppRgb);

            var ptr  = bmpData.Scan0;
            var data = new RGBData();

            unsafe
            {
                var p      = (byte *)(void *)ptr;
                var width  = a.Width * 3;
                var offset = bmpData.Stride - width;

                for (var y = 0; y < a.Height; ++y)
                {
                    for (var x = 0; x < width; ++x)
                    {
                        data.R += p[0]; // gets red values
                        data.G += p[1]; // gets green values
                        data.B += p[2]; // gets blue values
                        ++p;
                    }

                    p += offset;
                }
            }

            a.UnlockBits(bmpData);
            return(data);
        }
Exemplo n.º 2
0
 public async Task SendMessage([FromBody] RGBData data)
 {
     if (data != null)
     {
         await _notificationsMessageHandler.SendMessageToAllAsync(JsonConvert.SerializeObject(data));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Determines whether the specified
 ///     <see cref="BitmapCompare.RGBData"/> is equal to this instance.
 /// </summary>
 /// <param name="other">
 /// The <see cref="BitmapCompare.RGBData"/> to compare with this
 ///     instance.
 /// </param>
 /// <returns>
 /// <c>true</c> if the specified
 ///     <see cref="BitmapCompare.RGBData"/> is equal to this instance,
 ///     <c>false</c> otherwise.
 /// </returns>
 public bool Equals(RGBData other)
 {
     return(this.R == other.R && this.G == other.G && this.B == other.B);
 }