Beispiel #1
0
        public bool SendImageType(Service.ImageType imageType, bool value)
        {
            if (value)
            {
                sendImagesCount[imageType]++;
            }
            else
            {
                sendImagesCount[imageType]--;
            }

            bool willBeSend = serviceCommunicator.SendImageType(imageType, sendImagesCount[imageType] > 0);

            if (!willBeSend)
            {
                sendImagesCount[imageType] = 0;
            }
            return(willBeSend);
        }
        /// <summary>
        /// Tries the get camera image.
        /// </summary>
        /// <param name="imageType">Type of the image.</param>
        /// <param name="left">The left.</param>
        /// <param name="top">The top.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="imageData">The image data.</param>
        /// <returns></returns>
        public bool TryGetImage(ImageType imageType, int left, int top, int width, int height, out ImageData imageData)
        {
            bool result = false;

            imageData = null;

            Service.ImageType type = GetImageType(imageType);

            Service.ImageData image = data.Images.FirstOrDefault(i => i.Type == type);
            if (image != null)
            {
                int startAddress = top * image.Stride + left;
                int endAddress   = (top + height - 1) * image.Stride + (left + width);
                if (endAddress <= image.Data.Length)
                {
                    byte[] pixels = new byte[endAddress - startAddress];
                    Array.Copy(image.Data, startAddress, pixels, 0, pixels.Length);
                    imageData = new ImageData(width, height, image.Stride, image.BitsPerPixel, pixels);
                    result    = true;
                }
            }
            return(result);
        }
 public bool SendImageType(Service.ImageType imageType, bool value)
 {
     return(false);
 }
 public bool SendImageType(Service.ImageType imageType, bool value)
 {
     return(GetService().SendImageType(imageType, value));
 }