void AddImage_Clicked(System.Object sender, System.EventArgs e) { var index = _rand.Next(0, _buffer.Count()); index = 13; var im = SKImage.FromEncodedData(_buffer.ElementAt(index)).ToTextureImage(SkiaView.GRContext); var img = new MyImage() { Image = im }; if (_numberOfImages % 8 == 0) { _lastX = 0; _lastY += imagesize + _padding; } else { _lastX += imagesize + _padding; } img.Destination = new SKRect(_lastX, _lastY, _lastX + imagesize, _lastY + imagesize); _images.Add(img); _numberOfImages++; SkiaView.InvalidateSurface(); }
private void Pinch_PinchUpdated(object sender, PinchGestureUpdatedEventArgs e) { if (e.Status == GestureStatus.Started) { _startScale = _lastScale; } else if (e.Status == Xamarin.Forms.GestureStatus.Running) { _currentScale += (e.Scale - 1) * _startScale; _currentScale = Math.Max(0.003, _currentScale); _currentMatrix.ScaleX = (float)_currentScale; _currentMatrix.ScaleY = (float)_currentScale; SkiaView.InvalidateSurface(); } }
void RemoveImage_Clicked(System.Object sender, System.EventArgs e) { if (_images.Count() != 0) { _images.RemoveAt(_images.Count() - 1); _numberOfImages--; if (_numberOfImages % 5 == 0) { _lastX = 0; _lastY -= imagesize + _padding; } else { _lastX -= imagesize + _padding; } } SkiaView.InvalidateSurface(); }
void Quality_SelectedIndexChanged(System.Object sender, System.EventArgs e) { switch (QualityPicker.SelectedIndex) { case 0: _quality = SKFilterQuality.None; break; case 1: _quality = SKFilterQuality.Low; break; case 2: _quality = SKFilterQuality.Medium; break; case 3: _quality = SKFilterQuality.High; break; } SkiaView.InvalidateSurface(); }
private void SkiaView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { switch (e.ActionType) { case SkiaSharp.Views.Forms.SKTouchAction.Entered: _dragX = e.Location.X; _dragY = e.Location.Y; break; case SkiaSharp.Views.Forms.SKTouchAction.Moved: _currentMatrix.TransX = _dragX + e.Location.X; _currentMatrix.TransY = _dragY + e.Location.Y; SkiaView.InvalidateSurface(); break; case SkiaSharp.Views.Forms.SKTouchAction.Released: break; default: break; } }
private async Task DrawScaledUpImage() { if (_applyDitherBitmap == null) { return; } if (SkiaView.CanvasSize.Width > 0) { int newCanvasWidth = (int)SkiaView.CanvasSize.Width; int newCanvasHeight = (int)(SkiaView.CanvasSize.Width * (_applyDitherBitmap.Height / (double)_applyDitherBitmap.Width)); if ((int)SkiaView.CanvasSize.Width > (int)SkiaView.CanvasSize.Height) { newCanvasWidth = (int)(SkiaView.CanvasSize.Height * (_applyDitherBitmap.Width / (double)_applyDitherBitmap.Height)); newCanvasHeight = (int)SkiaView.CanvasSize.Height; } _drawBitmap = new SKBitmap(newCanvasWidth, newCanvasHeight); } _applyDitherBitmap.ScalePixels(_drawBitmap, SKFilterQuality.None); SkiaView.InvalidateSurface(); }
void ZoomOut_Clicked(System.Object sender, System.EventArgs e) { _currentMatrix.ScaleX -= _zoomFactor; _currentMatrix.ScaleY -= _zoomFactor; SkiaView.InvalidateSurface(); }