Esempio n. 1
0
		public Task<IImage> getImageFromMediaFile(MediaFile file)
		{
			return Task<IImage>.Factory.StartNew(() =>
				{
					var rawImage = getScaledAndRotatedImage(file, Constants.MaxPixelDimensionOfImages);

					//Initialize picked image
					PickedImage image = new PickedImage()
						{
							Name = System.IO.Path.GetFileName(file.Path),
							RawImage = rawImage
						};

					return image;
				});
		}
Esempio n. 2
0
		private async void cameraImageSelected(CameraImageSelectedMessage message)
		{
			if (message.ReceiverID == _receiverID)
			{
				IImage result = await Task<IImage>.Factory.StartNew(() =>
					{
						IImage image = null;
						if (message.Image != null)
						{
							image = new PickedImage()
							{
								Name = Guid.NewGuid().ToString() + ".jpg",
								RawImage = message.Image.GetRawBytes(Bitmap.CompressFormat.Jpeg)
							};
						}
						return image;
					});

				_selectImageCompletion.TrySetResult(result);
			}
		}
Esempio n. 3
0
		private async void libraryImageSelected(LibraryImageSelectedMessage message)
		{
			if (message.ReceiverID == _receiverID)
			{
				IImage result = await Task<IImage>.Factory.StartNew(() =>
					{
						IImage image = null;
						try
						{
							if (message.Path != null)
							{
								var path = message.Path;
								var file = new MediaFile(path, () => File.OpenRead(path));
								var rawImage = getScaledAndRotatedImage(file, Constants.MaxPixelDimensionOfImages);

								//Initialize picked image
								image = new PickedImage()
									{
										Name = System.IO.Path.GetFileName(path),
										RawImage = rawImage
									};
							}	
						}
						catch (Exception ex)
						{
							Tools.Logger.Log(ex, LoggingLevel.Error, true);	
						}

						return image;
					});

				_selectImageCompletion.TrySetResult(result);
			}
		}