private async Task SelectPicture() { Setup(); _imageSource = null; try { var mediaFile = await this._mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 500 }); _imageSource = ImageSource.FromStream(() => mediaFile.Source); var memoryStream = new MemoryStream(); await mediaFile.Source.CopyToAsync(memoryStream); byte[] imageAsByte = memoryStream.ToArray(); if (Device.OS == TargetPlatform.iOS) { await Navigation.PushModalAsync(new CropView(imageAsByte, Refresh)); } } catch (System.Exception ex) { Debug.WriteLine (ex.Message); } }
private async Task<Bitmap> GetBitmapAsync(ImageSource source) { var handler = GetHandler(source); var returnValue = (Bitmap)null; returnValue = await handler.LoadImageAsync(source, this.Context); return returnValue; }
public FullscreenImagePopup(Xamarin.Forms.ImageSource pic) { InitializeComponent(); pictureBoxFullScreen.Source = pic; closePicture(); }
public ImageViewModel(ImageSource source) { Source = source; EditCommand = new Command(EditImage); SaveCommand = new Command(SaveImage); RemoveCommand = new Command(RemoveImage); }
internal static ImageSourceBinding GetImageSourceBinding(ImageSource source) { if (source == null) { return null; } var uriImageSource = source as UriImageSource; if (uriImageSource != null) { return new ImageSourceBinding(FFImageLoading.Work.ImageSource.Url, uriImageSource.Uri.ToString()); } var fileImageSource = source as FileImageSource; if (fileImageSource != null) { if (File.Exists(fileImageSource.File)) return new ImageSourceBinding(FFImageLoading.Work.ImageSource.Filepath, fileImageSource.File); return new ImageSourceBinding(FFImageLoading.Work.ImageSource.ApplicationBundle, fileImageSource.File); } var streamImageSource = source as StreamImageSource; if (streamImageSource != null) { return new ImageSourceBinding(streamImageSource.Stream); } throw new NotImplementedException("ImageSource type not supported"); }
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { string base64 = value as string; if (base64 == null || String.IsNullOrEmpty(base64)) { return(null); } try { Byte[] buffer = Convert.FromBase64String(base64); Xamarin.Forms.ImageSource imageSource = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(buffer)); System.Diagnostics.Debug.WriteLine(value); return(imageSource); } catch (Exception ex) { AppConstants.Logger?.LogError(ex, new Dictionary <string, string> { { "Class", "Base64StringImageConverter" } }); } return(ImageSource.FromFile("DefaultAvatar.png")); }
public ShoppingListItem(int itemID, string itemName, double itemPrice, ImageSource itemImage) { this.ID = itemID; this.Name = itemName; this.ItemPrice = itemPrice; this.Image = itemImage; }
private void OpenCamera_click() { try { ImagePicker((string file, MediaFile mediafile) => { if (string.IsNullOrEmpty(file)) { return; } else { imageUrlMediaFile = mediafile; imageUrlfile = file; ImageUrl = ImageSource.FromFile(file); App.FrameImage = ImageUrl; byte[] b = File.ReadAllBytes(file); base64String = Convert.ToBase64String(b); if (!string.IsNullOrEmpty(base64String)) { App.base64String = "<img src=\"data:image/png;base64," + base64String + "\" alt=\"\">"; } } }); } catch (Exception ex) { Debug.WriteLine($"Exception: { ex.Message}"); } }
public ProductImagePage(ImageSource productImageSource) { Padding = Device.OnPlatform(new Thickness(0, 20, 0, 0), new Thickness(0), new Thickness(0)); _productImageSource = productImageSource; BackgroundColor = Color.FromRgba(0, 0, 0, 127); var absoluteLayout = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand }; var closeButtom = new Button { WidthRequest = 50, Image = "backspace.png", BackgroundColor = Color.Transparent }; closeButtom.Clicked += OnCloseButtonClicked; var image = new Image { Source = _productImageSource }; AbsoluteLayout.SetLayoutFlags(closeButtom, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(closeButtom, new Rectangle(1f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(image, new Rectangle(0.5f, 0.5f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); absoluteLayout.Children.Add(image); absoluteLayout.Children.Add(closeButtom); Content = absoluteLayout; }
public async Task <Bitmap> LoadImageAsync(Xamarin.Forms.ImageSource imageSource, Context context, CancellationToken cancellationToken = default) { try { if (!IsValid(context)) { return(null); } var source = ImageSourceBinding.GetImageSourceBinding(imageSource, null); if (source == null) { return(null); } var result = await LoadImageAsync(source, imageSource, context, cancellationToken); var target = result.Target as BitmapTarget; return(target?.BitmapDrawable?.Bitmap); } catch (Exception) { return(null); } }
public async void SetSource(ImageSource source) { try { if (!string.IsNullOrWhiteSpace(_cacheKey)) { await ImageService.Instance.InvalidateCacheEntryAsync(_cacheKey, FFImageLoading.Cache.CacheType.Memory, true); } if (!string.IsNullOrWhiteSpace(_refinedCacheKey)) { await ImageService.Instance.InvalidateCacheEntryAsync(_cacheKey, FFImageLoading.Cache.CacheType.Memory, true); } _imageGuid = Guid.NewGuid(); _cacheKey = _imageGuid.ToString(); _refinedCacheKey = $"{_imageGuid.ToString()}-Refined"; TaskParameter task = null; TaskParameter taskRefined = null; var fileSource = source as FileImageSource; if (fileSource != null) { task = ImageService.Instance.LoadFile(fileSource.File); taskRefined = ImageService.Instance.LoadFile(fileSource.File); } var urlSource = source as UriImageSource; if (urlSource != null) { task = ImageService.Instance.LoadUrl(urlSource.Uri?.OriginalString); taskRefined = ImageService.Instance.LoadUrl(urlSource.Uri?.OriginalString); } var streamSource = source as StreamImageSource; if (streamSource != null) { task = ImageService.Instance.LoadStream(streamSource.Stream); taskRefined = ImageService.Instance.LoadStream(streamSource.Stream); } using (var stream = await task.DownSample(PreviewResolution, PreviewResolution).AsJPGStreamAsync(90)) { byte[] bytes = StreamToByteArray(stream); _source = ImageSource.FromStream(() => new MemoryStream(bytes)); } using (var streamRefined = await taskRefined.DownSample(RefinedResolution, RefinedResolution).AsJPGStreamAsync(90)) { byte[] bytes = StreamToByteArray(streamRefined); _refinedSource = ImageSource.FromStream(() => new MemoryStream(bytes)); } LoadRefinedImage(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
public Image(Xamarin.Forms.ImageSource source = null) { if (source != null) { this.Source = source; } }
public ImageViewPage(ImageSource source, ImageCollectionViewModel icvm) { var vm = new ImageViewModel(source); _icvm = icvm; vm.EditPressed += OnEditPressed; BindingContext = vm; InitializeComponent(); }
public ImageSourceEventArgs(Uri imageSource, ImageSource source){ if (imageSource == null) throw new ArgumentNullException ("imagesource"); if (source == null) throw new ArgumentNullException ("source"); ImageSource = imageSource; Source = source; }
public Image(ICanvasResourceCreator resourceCreator, Xamarin.Forms.ImageSource source = null) { this.resourceCreator = resourceCreator; if (source != null) { this.Source = source; } }
public bool newSigil(String Fname) { img = ImageSource.FromFile(Fname); if (img == null) return false; else return true; }
//loads the image for the container and returns a ImageSource public static Xamarin.Forms.ImageSource LoadImage(StorageContainer containerIn) { int id = containerIn.GetId(); Xamarin.Forms.ImageSource returnSource = LoadImage(Path.Combine(Directories.containerImageDirectory, id.ToString() + ".jpg")); ImageBaseHandler.current.AddContainerImage(containerIn.GetId(), returnSource); return(returnSource); }
//loads the image for the item and returns a ImageSource public static Xamarin.Forms.ImageSource LoadImage(Item itemIn) { int id = itemIn.GetId(); Xamarin.Forms.ImageSource returnSource = LoadImage(Path.Combine(Directories.itemImageDirectory, id.ToString() + ".jpg")); ImageBaseHandler.current.AddItemImage(itemIn.GetId(), returnSource); return(returnSource); }
//loads the image for the location and returns a ImageSource public static Xamarin.Forms.ImageSource LoadImage(StorageLocation locationIn) { int id = locationIn.GetId(); Xamarin.Forms.ImageSource returnSource = LoadImage(Path.Combine(Directories.locationImageDirectory, id.ToString() + ".jpg")); ImageBaseHandler.current.AddLocationImage(locationIn.GetId(), returnSource); return(returnSource); }
void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) { if (newvalue != null) { newvalue.SourceChanged += OnSourceChanged; SetInheritedBindingContext(newvalue, BindingContext); } }
private async void TakePhotoMethod() { var file = await CameraHelper.TakePhoto(); if (file != null) { Image = ImageSource.FromStream(() => file.GetStream()); } }
public Person(string name, string city, string depertment, int age, int followers, ImageSource photo) { this.Name = name; this.City = city; this.Department = depertment; this.Age = age; this.Followers = followers; this.Photo = photo; }
public ProfileViewModel(FindUser user) { user = (user == null) ? MainViewModel.GetInstance().GetUser : user; this.Email = user.Email; this.Name = user.Name; this.LastName = user.LastName; this.Image = "profile.png"; CameraHelper = new CameraHelper(); }
protected override void OnPropertyChanged(string propertyName) { base.OnPropertyChanged(propertyName); if (BindingContext != null) { BackgroundImage = ((HomeViewModel)BindingContext).BackgroundImage; } }
/// <summary> /// Create image. Supported image source is currently embedded resource. /// </summary> /// <param name="source">Image source.</param> /// <returns>Image</returns> public IImage CreateImage(Xamarin.Forms.ImageSource source) { if (renderer == null) { return(null); } return(renderer.CreateImage(source)); }
public static async Task <UWPImage> GetImageFromImageSourceAsync(XamarinImageSource source) { var handler = GetHandler(source); var returnValue = (UWPImage)null; returnValue = await handler.LoadImageAsync(source); return(returnValue); }
private Bitmap GetBitmap(Xamarin.Forms.ImageSource image) { var task = Task.Run <Bitmap>(async() => { return(await new ImageLoaderSourceHandler().LoadImageAsync(image, Context)); }); //var x = t.Result; return(task.Result); }
private void Instance_DownloadCompleted(ImageSource image) { stopwatch.Stop(); Device.BeginInvokeOnMainThread(() => { downloadedImage.Source = image; timeLabel.Text = stopwatch.GetDurationInSeconds(); RefreshUI(false); }); }
public MainPageViewModel() { this.SecondHand = ImageSource.FromResource("ReactiveExtentionsPOC.Images.clock_second_hand.jpg"); var oneNumberPerSecond = Observable.Interval(TimeSpan.FromSeconds(1)); oneNumberPerSecond.Subscribe(num => { this.Rotation = (Convert.ToInt32(num) * (360/60)); }); }
public EditImageViewPage(ImageSource source, ImageCollectionViewModel icvm) { InitializeComponent(); _icvm = icvm; _vm = new ImageViewModel(source); _vm.RemovePressed += GoBack; _vm.RemovePressed += _icvm.Remove; _vm.SavePressed += GoBack; _vm.SavePressed += _icvm.SaveImageToGallery; BindingContext = _vm; }
public XamagonXuzzleTile (int row, int col, ImageSource imageSource) { Row = row; Col = col; Padding = new Thickness(1); Content = new Image { Source = imageSource }; }
/// <summary> /// Returns the proper <see cref="T:Xamarin.Forms.Platform.iOS.IImageSourceHandler"/> /// based on the type of <see cref="T:Xamarin.Forms.ImageSource"/> provided. /// </summary> /// <param name="source">The <see cref="T:Xamarin.Forms.ImageSource"/> to get the handler for.</param> /// <returns> /// The needed handler. /// </returns> private static IImageSourceHandler GetHandler(ImageSource source) { var imageSourceHandler = (IImageSourceHandler)null; if(source is UriImageSource) imageSourceHandler = new ImageLoaderSourceHandler(); else if(source is FileImageSource) imageSourceHandler = new FileImageSourceHandler(); else if(source is StreamImageSource) imageSourceHandler = new StreamImagesourceHandler(); return imageSourceHandler; }
public HightlightedImageButton(Xamarin.Forms.ImageSource imgSource) : base() { imageContent = new CachedImage(); imageContent.Source = imgSource; this.Content = imageContent; this.LongPressed += (sen, e) => Highlight(); InitHighlight(); }
public Card(bool scanned, string redactedCardNumber, string postalCode, int expiryYear, int expiryMonth, string cvv, CreditCardType cardType, string cardNumber, ImageSource cardImage) { this.Scaned = scanned; this.RedactedCardNumber = redactedCardNumber; this.PostalCode = postalCode; this.ExpiryYear = expiryYear; this.ExpiryMonth = expiryMonth; this.Cvv = cvv; this.CardType = cardType; this.CardNumber = cardNumber; this.CardImage = cardImage; }
/// <summary> /// Returns the proper <see cref="IImageSourceHandler"/> based on the type of <see cref="ImageSource"/> provided. /// </summary> /// <param name="source">The <see cref="ImageSource"/> to get the handler for.</param> /// <returns>The needed handler.</returns> private static IImageSourceHandler GetHandler(ImageSource source) { IImageSourceHandler returnValue = null; if (source is UriImageSource) { returnValue = new ImageLoaderSourceHandler (); } else if (source is FileImageSource) { returnValue = new FileImageSourceHandler (); } else if (source is StreamImageSource) { returnValue = new StreamImagesourceHandler (); } return returnValue; }
public Task<IControl> GetImageAsync(ImageSource imageSource, ImageFormat format, CancellationToken cancellationToken) { var fileSource = (FileImageSource)imageSource; string asset = fileSource.File; if (format == ImageFormat.Unknown) format = ImageFactory.DetectFormat(asset); string cacheKey = format.ToString() + "|" + asset; return _cachedImages.GetOrAdd(cacheKey, k => GetImage(fileSource, format)); }
protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == SourceProperty.PropertyName) { if (this.defaultSource == null) this.defaultSource = this.Source; } if (propertyName == IsCheckedProperty.PropertyName) { this.Source = this.IsChecked ? this.IsCheckedImageSource : this.defaultSource; } }
private static IImageSourceHandler GetHandler(XamarinImageSource source) { IImageSourceHandler returnValue = null; if (source is FileImageSource) { returnValue = new FileImageSourceHandler(); } else if (source is StreamImageSource) { returnValue = null; } return(returnValue); }
public async Task<bool> SaveImage(ImageSource img, string imageName) { var render = new StreamImagesourceHandler(); image = await render.LoadImageAsync(img); var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var nomeImagem = Path.Combine(path, imageName); NSData imgData = image.AsJPEG(); NSError erro = null; return imgData.Save(nomeImagem, false, out erro); }
internal static async Task <ImageSourceBinding> GetImageSourceBinding(Xamarin.Forms.ImageSource source) { if (source == null) { return(null); } var uriImageSource = source as UriImageSource; if (uriImageSource != null) { return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.Url, uriImageSource.Uri.ToString())); } var fileImageSource = source as FileImageSource; if (fileImageSource != null) { StorageFile file = null; try { var filePath = System.IO.Path.GetDirectoryName(fileImageSource.File); if (!string.IsNullOrWhiteSpace(filePath)) { file = await StorageFile.GetFileFromPathAsync(fileImageSource.File); } } catch (Exception) { } if (file != null) { return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.Filepath, fileImageSource.File)); } return(new ImageSourceBinding(FFImageLoading.Work.ImageSource.ApplicationBundle, fileImageSource.File)); } var streamImageSource = source as StreamImageSource; if (streamImageSource != null) { return(new ImageSourceBinding(streamImageSource.Stream)); } throw new NotImplementedException("ImageSource type not supported"); }
public TaskCheckerPopUp(FriendUpdate friendUpdate) { InitializeComponent(); TaskName.Text = friendUpdate.task.taskname; TaskOwner.Text = "What " + friendUpdate.username + " just did:"; Xamarin.Forms.ImageSource image = ImageSource.FromFile(friendUpdate.imageAddress); PhotoImage.Source = image; if (friendUpdate.userid == Constants.me.userid) { Check.IsVisible = false; } this.friendUpdate = friendUpdate; BindingContext = this; }
public Task<IControl> GetImageAsync(ImageSource imageSource, ImageFormat format, CancellationToken cancellationToken) { var uriSource = (UriImageSource)imageSource; if (uriSource.Uri.Scheme == "pack") uriSource.CachingEnabled = false; string asset = uriSource.Uri.ToString(); if (format == ImageFormat.Unknown) format = ImageFactory.DetectFormat(asset); string cacheKey = format.ToString() + "|" + asset; return _cachedImages.GetOrAdd(cacheKey, k => GetImage(uriSource, format)); }
static SKBitmap LoadBitmap(Xamarin.Forms.ImageSource src) { switch (src) { case FileImageSource file: break; case StreamImageSource stream: break; case UriImageSource uri: break; } return(null); }
public object ProvideValue(IServiceProvider serviceProvider) { if (Source == null) { return(null); } IProfileStore <Profile> DataStore = DependencyService.Get <IProfileStore <Profile> >(); Profile profileFromAzure = null; Task.Run(async() => { try { profileFromAzure = await DataStore.GetItemAsync(Source); } catch (Exception ex) { AppConstants.Logger?.Log("ImageCloudExtension-Exception"); } return(true); }).Wait(); string s = string.Empty; if (profileFromAzure != null) { s = profileFromAzure.PhotoBase64Encoded; Byte[] buffer = Convert.FromBase64String(s); Xamarin.Forms.ImageSource imageSource = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(buffer)); System.Diagnostics.Debug.WriteLine(Source); return(imageSource); } //if (String.Compare(Source, "sbovo") == 0) //{ // s = @"/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIALIAsgMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU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/0oD8+dB0s4IOVuz2r/EMHvW4wJpp9p7XHwsLHmapz4rzgHPtnNNCao+8nR81P3FxRSvT8aMA1toz5KZginNxq3nvHo+bpKTPREUdWcxtZQffc3Yk8PQ2OeR8ZOFH/N4J7ac+az2kvqiZ94wmqNoZuBWNGY47/A1YA9z61p76bAAAAAElFTkSuQmCC"; //} return(null); }
public LoginPage() { InitializeComponent(); BindingContext = vm = new LoginViewModel(Navigation); if (!Settings.Current.FirstRun) { Title = "My Account"; var cancel = new ToolbarItem { Text = "Cancel", Command = new Command(async() => { if(vm.IsBusy) return; await Navigation.PopModalAsync(); }) }; ToolbarItems.Add(cancel); if (Device.OS != TargetPlatform.iOS) cancel.Icon = "toolbar_close.png"; } CircleImageAvatar.Source = placeholder = ImageSource.FromFile("profile_generic_big.png"); EntryEmail.TextChanged += (sender, e) => { var isValid = (Regex.IsMatch(e.NewTextValue, emailRegex, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250))); if(isValid) { Device.BeginInvokeOnMainThread(()=> { CircleImageAvatar.BorderThickness = 3; CircleImageAvatar.Source = ImageSource.FromUri(new Uri(Gravatar.GetURL(EntryEmail.Text))); }); } else if(CircleImageAvatar.Source != placeholder) { Device.BeginInvokeOnMainThread(()=> { CircleImageAvatar.BorderThickness = 0; CircleImageAvatar.Source = placeholder; }); } }; }
public void CacheFromFile(String file) { if (!_store.ContainsKey(file)) { Xamarin.Forms.ImageSource source = Xamarin.Forms.ImageSource.FromFile(file); var imageHandler = source.GetLoaderHandler(); if (imageHandler != null) { var nativeImage = imageHandler.LoadImageAsync(source); if (nativeImage != null && nativeImage.Status != TaskStatus.Faulted) { _store[file] = nativeImage.Result; System.Diagnostics.Debug.WriteLine("PIC CACHED " + file); } } } }
public async void CacheFromFileAync(String file) { if (!_store.ContainsKey(file)) { Xamarin.Forms.ImageSource source = Xamarin.Forms.ImageSource.FromFile(file); var imageHandler = source.GetLoaderHandler(); if (imageHandler != null) { var nativeImage = await imageHandler.LoadImageAsync(source); if (nativeImage != null) { _store[file] = nativeImage; } } } }
async void Share (ImageSource imageSource) { var handler = new ImageLoaderSourceHandler(); var uiImage = await handler.LoadImageAsync(imageSource); var item = NSObject.FromObject (uiImage); var activityItems = new[] { item }; var activityController = new UIActivityViewController (activityItems, null); var topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } topController.PresentViewController (activityController, true, () => {}); }
//добавить новое фото private async void Bt_add_photo_Clicked(object sender, EventArgs e) { try { if (CrossMedia.Current.IsPickPhotoSupported) { MediaFile photo = await CrossMedia.Current.PickPhotoAsync(); Xamarin.Forms.ImageSource img = Xamarin.Forms.ImageSource.FromFile(photo.Path); if (currentNotice == null) { imgSource.Add(photo.Path); } else { if (photo.Path != null && photo.Path != "") { //tempImgSource.Add(photo.Path); //images.Add(new ServerImage(photo.Path)); WebClient myWebClient = new WebClient(); myWebClient.QueryString = new System.Collections.Specialized.NameValueCollection { { "notice_id",currentNotice.Id.ToString() } }; byte[] responseArray = myWebClient.UploadFile(ApiService.URL_ADD_MEDIA, photo.Path); var ans = System.Text.Encoding.ASCII.GetString(responseArray); JObject o = JObject.Parse(ans); if ((bool)o["status"]) { await DisplayAlert("Success", "Image was added", "OK"); OnAppearing(); } else { await DisplayAlert("Warning", "Image was not added", "Done"); } } } } }catch(Exception ex) { await DisplayAlert("Error", ex.Message, "Done"); } }//Bt_add_photo_Clicked
private IImageSourceHandler GetHandler(Xamarin.Forms.ImageSource imageSource) { IImageSourceHandler returnValue = null; if (imageSource is Xamarin.Forms.UriImageSource) { returnValue = new UriImageSourceHandler(); } else if (imageSource is Xamarin.Forms.FileImageSource) { returnValue = new FileImageSourceHandler(); } else if (imageSource is Xamarin.Forms.StreamImageSource) { returnValue = new StreamImageSourceHandler(); } return(returnValue); }
public static ImageSource FromResource(string source) { if (string.IsNullOrEmpty(source)) { return(null); } Assembly assembly = typeof(ImageResourceExtension).GetTypeInfo().Assembly; if (!source.StartsWith("com.")) { source = "ChineseJourney.Common.Resources." + source; } if (!source.EndsWith(".png")) { source += ".png"; } return(ImageSource.FromResource(source, assembly)); }
private static async Task ShareImageAsyc(ImageSource image, string message, string url = null) { var handler = image.GetHandler(); if (handler == null) return; var uiImage = await handler.LoadImageAsync(image); var items = new List<NSObject> { new NSString(message ?? string.Empty) }; if (!url.IsNullOrEmpty()) items.Add(new NSString(url)); items.Add(uiImage); var controller = new UIActivityViewController(items.ToArray(), null); UIApplication.SharedApplication.KeyWindow.RootViewController.GetTopViewController() .PresentViewController(controller, true, null); }
public Game() { InitializeComponent(); _blank = ImageSource.FromResource("MineSweeper.Images.blank.png"); _mine = ImageSource.FromResource("MineSweeper.Images.mine.png"); _nomine = ImageSource.FromResource("MineSweeper.Images.nomine.png"); _explodedmine = ImageSource.FromResource("MineSweeper.Images.explodedmine.png"); _flag = ImageSource.FromResource("MineSweeper.Images.flag.png"); _1 = ImageSource.FromResource("MineSweeper.Images.1.png"); _2 = ImageSource.FromResource("MineSweeper.Images.2.png"); _3 = ImageSource.FromResource("MineSweeper.Images.3.png"); _4 = ImageSource.FromResource("MineSweeper.Images.4.png"); _5 = ImageSource.FromResource("MineSweeper.Images.5.png"); _6 = ImageSource.FromResource("MineSweeper.Images.6.png"); _7 = ImageSource.FromResource("MineSweeper.Images.7.png"); _8 = ImageSource.FromResource("MineSweeper.Images.8.png"); }
public async void SavePictureToDisk (ImageSource imgSrc, int Id) { var renderer = new StreamImagesourceHandler (); var photo = await renderer.LoadImageAsync (imgSrc); var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal); string jpgFilename = System.IO.Path.Combine ( documentsDirectory, Id.ToString () + ".jpg"); NSData imgData = photo.AsJPEG (); NSError err = null; if (imgData.Save (jpgFilename, false, out err)) { Console.WriteLine ("saved as " + jpgFilename); } else { Console.WriteLine ("NOT saved as " + jpgFilename + " because" + err.LocalizedDescription); } }
private static IImageSourceHandler GetHandler(Xamarin.Forms.ImageSource source) { IImageSourceHandler returnValue = null; if (source is UriImageSource) { returnValue = new ImageLoaderSourceHandler(); } else if (source is FileImageSource) { returnValue = new FileImageSourceHandler(); } else if (source is StreamImageSource) { returnValue = new StreamImagesourceHandler(); } return(returnValue); }
public string GetKey(Xamarin.Forms.ImageSource imageSource, object bindingContext) { if (imageSource == null) { return(null); } string itemSuffix = string.Empty; var bindingItem = bindingContext as ByteArrayToImageConverter; if (bindingItem != null) { itemSuffix = bindingItem.ToString(); } // UriImageSource var uriImageSource = imageSource as UriImageSource; if (uriImageSource != null) { return(string.Format("{0}+myCustomUriSuffix+{1}", uriImageSource.Uri, itemSuffix)); } // FileImageSource var fileImageSource = imageSource as FileImageSource; if (fileImageSource != null) { return(string.Format("{0}+myCustomFileSuffix+{1}", fileImageSource.File, itemSuffix)); } // StreamImageSource var streamImageSource = imageSource as StreamImageSource; if (streamImageSource != null) { return(string.Format("{0}+myCustomStreamSuffix+{1}", streamImageSource.Stream.GetHashCode(), itemSuffix)); } //var byteimagesource = byte[] imageAsBytes = (byte[]bindingContext); ////retSource = ImageSource.FromStream(() => new MemoryStream(imageAsBytes)); throw new NotImplementedException("ImageSource type not supported"); }
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { string UserName = value as string; if (UserName == null || String.IsNullOrEmpty(UserName)) { return(null); } IProfileStore <Profile> DataStore = DependencyService.Get <IProfileStore <Profile> >(); Profile profileFromAzure = null; Task.Run(async() => { try { profileFromAzure = await DataStore.GetItemAsync(UserName); } catch (Exception ex) { AppConstants.Logger?.Log("ImageAzureExtension-Exception"); } return(true); }).Wait(); string s = string.Empty; if (profileFromAzure != null) { s = profileFromAzure.PhotoBase64Encoded; Byte[] buffer = Convert.FromBase64String(s); Xamarin.Forms.ImageSource imageSource = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(buffer)); System.Diagnostics.Debug.WriteLine(value); return(imageSource); } return(null); }
async void TakePicture(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", "No Persmission to use Camera", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync( new StoreCameraMediaOptions { SaveToAlbum = false, PhotoSize = PhotoSize.Small }); var img = ImageSource.FromStream(() => { using (var memoryStream = new MemoryStream()) { file.GetStream().CopyTo(memoryStream); vm.Bytes = memoryStream.ToArray(); } var stream = file.GetStream(); file.Dispose(); return(stream); }); vm.UsedBytes = null; TakenPicture.Source = img; vm.Picture = img; EditPictureButton.IsEnabled = true; SavePictureButton.IsEnabled = true; if (file == null) { return; } }
public async Task<bool> SaveImage(ImageSource img, string imageName) { try { var renderer = new StreamImagesourceHandler(); imagem = await renderer.LoadImageAsync(img, Forms.Context); var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string pngPath = System.IO.Path.Combine(documentsDirectory, imageName + ".png"); using (System.IO.FileStream fs = new System.IO.FileStream(pngPath, System.IO.FileMode.OpenOrCreate)) { imagem.Compress(Bitmap.CompressFormat.Png, 100, fs); return await Task.FromResult<bool>(true); } } catch (Exception) { return await Task.FromResult<bool>(false); } }
internal static ImageSourceBinding GetImageSourceBinding(ImageSource source) { if (source == null) { return null; } var uriImageSource = source as UriImageSource; if (uriImageSource != null) { return new ImageSourceBinding(FFImageLoading.Work.ImageSource.Url, uriImageSource.Uri.ToString()); } var fileImageSource = source as FileImageSource; if (fileImageSource != null) { return new ImageSourceBinding(FFImageLoading.Work.ImageSource.CompiledResource, fileImageSource.File); } throw new NotImplementedException("ImageSource type not supported"); }