Class SkiaImage
public class SkiaImage : SkiaControl, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IVisualElementController, IElementController, IView, ITransform, IElement, IVisualTreeElement, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISkiaGestureListener, IHasAfterEffects, ISkiaControl, IDrawnBase, ICanBeUpdatedWithContext, ICanBeUpdated, ISkiaDisposable, IDisposable
- Inheritance
-
SkiaImage
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
SkiaImage()
public SkiaImage()
SkiaImage(string)
public SkiaImage(string source)
Parameters
sourcestring
Fields
AddEffectProperty
public static readonly BindableProperty AddEffectProperty
Field Value
AspectProperty
public static readonly BindableProperty AspectProperty
Field Value
BlurProperty
public static readonly BindableProperty BlurProperty
Field Value
BrightnessProperty
public static readonly BindableProperty BrightnessProperty
Field Value
CacheRescaledSourceProperty
public static readonly BindableProperty CacheRescaledSourceProperty
Field Value
CancelLoading
public CancellationTokenSource CancelLoading
Field Value
ClipSource
public bool ClipSource
Field Value
ColorTintProperty
public static readonly BindableProperty ColorTintProperty
Field Value
ContrastProperty
public static readonly BindableProperty ContrastProperty
Field Value
DarkenProperty
public static readonly BindableProperty DarkenProperty
Field Value
DrawWhenEmptyProperty
public static readonly BindableProperty DrawWhenEmptyProperty
Field Value
EffectBlendModeProperty
public static readonly BindableProperty EffectBlendModeProperty
Field Value
EndColorProperty
public static readonly BindableProperty EndColorProperty
Field Value
EraseChangedContentProperty
public static readonly BindableProperty EraseChangedContentProperty
Field Value
GammaProperty
public static readonly BindableProperty GammaProperty
Field Value
HorizontalAlignmentProperty
public static readonly BindableProperty HorizontalAlignmentProperty
Field Value
HorizontalOffsetProperty
public static readonly BindableProperty HorizontalOffsetProperty
Field Value
ImageBitmapProperty
public static readonly BindableProperty ImageBitmapProperty
Field Value
ImagePaint
Reusing this
protected SKPaint ImagePaint
Field Value
InflateAmountProperty
public static readonly BindableProperty InflateAmountProperty
Field Value
LightenProperty
public static readonly BindableProperty LightenProperty
Field Value
LoadSourceOnFirstDrawProperty
public static readonly BindableProperty LoadSourceOnFirstDrawProperty
Field Value
LogEnabled
public static bool LogEnabled
Field Value
PaintColorFilter
Reusing this
protected SKColorFilter PaintColorFilter
Field Value
PaintImageFilter
Reusing this
public SKImageFilter PaintImageFilter
Field Value
PreviewBase64Property
public static readonly BindableProperty PreviewBase64Property
Field Value
RescaleSourceProperty
public static readonly BindableProperty RescaleSourceProperty
Field Value
RescalingQualityProperty
public static readonly BindableProperty RescalingQualityProperty
Field Value
SaturationProperty
public static readonly BindableProperty SaturationProperty
Field Value
SourceProperty
public static readonly BindableProperty SourceProperty
Field Value
SpriteHeightProperty
public static readonly BindableProperty SpriteHeightProperty
Field Value
SpriteIndexProperty
public static readonly BindableProperty SpriteIndexProperty
Field Value
SpriteWidthProperty
public static readonly BindableProperty SpriteWidthProperty
Field Value
StartColorProperty
public static readonly BindableProperty StartColorProperty
Field Value
UseAssemblyProperty
public static readonly BindableProperty UseAssemblyProperty
Field Value
UseGradientProperty
public static readonly BindableProperty UseGradientProperty
Field Value
VerticalAlignmentProperty
public static readonly BindableProperty VerticalAlignmentProperty
Field Value
VerticalOffsetProperty
public static readonly BindableProperty VerticalOffsetProperty
Field Value
ZoomXProperty
public static readonly BindableProperty ZoomXProperty
Field Value
ZoomYProperty
public static readonly BindableProperty ZoomYProperty
Field Value
Properties
AddEffect
public SkiaImageEffect AddEffect { get; set; }
Property Value
ApplyNewSource
protected LoadedImageSource ApplyNewSource { get; set; }
Property Value
Aspect
Apspect to render image with, default is AspectCover.
public TransformAspect Aspect { get; set; }
Property Value
AspectScale
public SKPoint AspectScale { get; protected set; }
Property Value
Blur
public double Blur { get; set; }
Property Value
Brightness
public double Brightness { get; set; }
Property Value
CacheRescaledSource
Defines if we should cached the rescaled source when RescalingQuality is set or apply the quality on every draw instead. Default is true. You might want to set this to false for very fast changing source, like camera/video feed etc.
public bool CacheRescaledSource { get; set; }
Property Value
CachedImage
Provides a cached image if any
public override SKImage CachedImage { get; }
Property Value
CanDraw
public override bool CanDraw { get; }
Property Value
ColorTint
public Color ColorTint { get; set; }
Property Value
Contrast
public double Contrast { get; set; }
Property Value
Darken
public double Darken { get; set; }
Property Value
DisplayRect
public SKRect DisplayRect { get; set; }
Property Value
DrawWhenEmpty
public bool DrawWhenEmpty { get; set; }
Property Value
EffectBlendMode
public SKBlendMode EffectBlendMode { get; set; }
Property Value
EndColor
public Color EndColor { get; set; }
Property Value
EraseChangedContent
Should we erase the existing image when another Source is set but wasn't applied yet (not loaded yet)
public bool EraseChangedContent { get; set; }
Property Value
Gamma
public double Gamma { get; set; }
Property Value
HasError
public bool HasError { get; protected set; }
Property Value
HasUnstableSize
Set this to true for cases when your image is auto-sized and changing the source should re-measure it again.
public bool HasUnstableSize { get; set; }
Property Value
HorizontalAlignment
public DrawImageAlignment HorizontalAlignment { get; set; }
Property Value
HorizontalOffset
public double HorizontalOffset { get; set; }
Property Value
ImageBitmap
this is the source loaded, doesn't reflect any effects or any other rendering properties
public LoadedImageSource ImageBitmap { get; set; }
Property Value
ImageSource
public ImageSource ImageSource { get; protected set; }
Property Value
InflateAmount
public double InflateAmount { get; set; }
Property Value
IsLoading
public bool IsLoading { get; set; }
Property Value
LastSource
Last source that we where loading. Td be reused for reload..
public ImageSource LastSource { get; protected set; }
Property Value
Lighten
public double Lighten { get; set; }
Property Value
LoadSource
public Action LoadSource { get; protected set; }
Property Value
LoadSourceOnFirstDraw
Should the source be loaded on the first draw, useful for the first fast rendering of the screen and loading images after, default is False. Set this to False if you need an off-screen loading and to True to make the screen load faster. While images are loaded in async manner this still has its impact. Useful to set True for for SkiaCarousel cells etc..
public bool LoadSourceOnFirstDraw { get; set; }
Property Value
LoadedSource
public LoadedImageSource LoadedSource { get; set; }
Property Value
NeedInvalidateColorFilter
protected bool NeedInvalidateColorFilter { get; set; }
Property Value
NeedInvalidateImageFilter
protected bool NeedInvalidateImageFilter { get; set; }
Property Value
PreviewBase64
If setting in code-behind must be set BEFORE you change the Source
public string PreviewBase64 { get; set; }
Property Value
RescaleSource
Should rescale source if output viewport size changed and RescalingQuality>none. Default value is false.
public bool RescaleSource { get; set; }
Property Value
RescalingQuality
Default value is Low.
public SKFilterQuality RescalingQuality { get; set; }
Property Value
Saturation
public double Saturation { get; set; }
Property Value
ScaledSource
public SkiaImage.RescaledBitmap ScaledSource { get; protected set; }
Property Value
Source
[TypeConverter(typeof(FrameworkImageSourceConverter))]
public ImageSource Source { get; set; }
Property Value
SourceHeight
From current set Source in points
public float SourceHeight { get; protected set; }
Property Value
SourceImageSize
public ScaledRect SourceImageSize { get; protected set; }
Property Value
SourceWidth
From current set Source in points
public float SourceWidth { get; protected set; }
Property Value
SpriteHeight
public double SpriteHeight { get; set; }
Property Value
SpriteIndex
public int SpriteIndex { get; set; }
Property Value
SpriteWidth
public double SpriteWidth { get; set; }
Property Value
StartColor
public Color StartColor { get; set; }
Property Value
TextureScale
public SKPoint TextureScale { get; protected set; }
Property Value
UseAssembly
public object UseAssembly { get; set; }
Property Value
UseGradient
public bool UseGradient { get; set; }
Property Value
VerticalAlignment
public DrawImageAlignment VerticalAlignment { get; set; }
Property Value
VerticalOffset
public double VerticalOffset { get; set; }
Property Value
ZoomX
public double ZoomX { get; set; }
Property Value
ZoomY
public double ZoomY { get; set; }
Property Value
Methods
AvoidRemeasuring(MeasureRequest)
public override bool AvoidRemeasuring(MeasureRequest request)
Parameters
requestMeasureRequest
Returns
CalculateDisplayRect(SKRect, float, float, DrawImageAlignment, DrawImageAlignment)
protected virtual SKRect CalculateDisplayRect(SKRect dest, float destWidth, float destHeight, DrawImageAlignment horizontal, DrawImageAlignment vertical)
Parameters
destSKRectdestWidthfloatdestHeightfloathorizontalDrawImageAlignmentverticalDrawImageAlignment
Returns
ClearBitmap()
public virtual void ClearBitmap()
Draw(DrawingContext)
protected override void Draw(DrawingContext context)
Parameters
contextDrawingContext
DrawSource(DrawingContext, LoadedImageSource, TransformAspect, DrawImageAlignment, DrawImageAlignment, SKPaint)
Updated DrawSource with professional-quality resizing
protected virtual void DrawSource(DrawingContext ctx, LoadedImageSource source, TransformAspect stretch, DrawImageAlignment horizontal = DrawImageAlignment.Center, DrawImageAlignment vertical = DrawImageAlignment.Center, SKPaint paint = null)
Parameters
ctxDrawingContextsourceLoadedImageSourcestretchTransformAspecthorizontalDrawImageAlignmentverticalDrawImageAlignmentpaintSKPaint
DrawSourceBitmap(DrawingContext, SKBitmap, SKRect, SKPaint, SKFilterQuality)
protected virtual void DrawSourceBitmap(DrawingContext ctx, SKBitmap bitmap, SKRect display, SKPaint paint, SKFilterQuality quality = SKFilterQuality.None)
Parameters
ctxDrawingContextbitmapSKBitmapdisplaySKRectpaintSKPaintqualitySKFilterQuality
DrawSourceImage(DrawingContext, SKImage, SKRect, SKPaint, SKFilterQuality)
protected virtual void DrawSourceImage(DrawingContext ctx, SKImage image, SKRect display, SKPaint paint, SKFilterQuality quality = SKFilterQuality.None)
Parameters
ctxDrawingContextimageSKImagedisplaySKRectpaintSKPaintqualitySKFilterQuality
GetRenderedSource()
Will render on an off-screen surface and return result. Contains all the effects and other rendering properties applied, size will correspond to source.
public virtual SKImage GetRenderedSource()
Returns
GetSamplingOptions(SKFilterQuality, bool)
Gets sampling options based on quality level
public static SKSamplingOptions GetSamplingOptions(SKFilterQuality quality, bool isUpscaling)
Parameters
qualitySKFilterQualityQuality level from user selection
isUpscalingboolWhether the operation is upscaling
Returns
- SKSamplingOptions
Appropriate SKSamplingOptions
Invalidate()
Base calls InvalidateInternal and InvalidateParent
public override void Invalidate()
InvalidateColorFilter()
public virtual void InvalidateColorFilter()
InvalidateImageFilter()
public virtual void InvalidateImageFilter()
LoadImageManagedAsync(ImageSource, CancellationTokenSource, LoadPriority)
protected virtual Task<SKBitmap> LoadImageManagedAsync(ImageSource source, CancellationTokenSource cancel, LoadPriority priority = LoadPriority.Normal)
Parameters
sourceImageSourcecancelCancellationTokenSourcepriorityLoadPriority
Returns
LoadSourceIfNeeded()
public virtual void LoadSourceIfNeeded()
OnDisposing()
Base performs some cleanup actions with Superview
public override void OnDisposing()
OnError(string)
public virtual void OnError(string source)
Parameters
sourcestring
OnLayoutChanged()
DrawingRect size changed
protected override void OnLayoutChanged()
OnMeasuring(float, float, float)
Input in POINTS
public override ScaledSize OnMeasuring(float widthRequest, float heightRequest, float dscale)
Parameters
Returns
OnScaleChanged()
public override void OnScaleChanged()
OnSuccess(string)
public virtual void OnSuccess(string source)
Parameters
sourcestring
OnWillDisposeWithChildren()
The OnDisposing might come with a delay to avoid disposing resources at use. This method will be called without delay when Dispose() is invoked. Disposed will set to True and for Views their OnWillDisposeWithChildren will be called.
public override void OnWillDisposeWithChildren()
Paint(DrawingContext)
This is the main drawing routine you should override to draw something. Base one paints background color inside DrawingRect that was defined by Arrange inside base.Draw. Pass arguments if you want to use some time-frozen data for painting at any time from any thread..
protected override void Paint(DrawingContext ctx)
Parameters
ctxDrawingContext
ReloadSource()
public virtual void ReloadSource()
SetAspectScale(int, int, SKRect, TransformAspect, float)
protected void SetAspectScale(int pxWidth, int pxHeight, SKRect dest, TransformAspect stretch, float scale)
Parameters
pxWidthintpxHeightintdestSKRectstretchTransformAspectscalefloat
SetBitmapInternal(SKBitmap, bool)
Use only if you know what to do, this internally just sets the new bitmap without any invalidations and not forcing an update. You would want to set InstancedBitmap prop for a usual approach.
public LoadedImageSource SetBitmapInternal(SKBitmap bitmap, bool protectFromDispose = false)
Parameters
Returns
SetFromBase64(string)
public void SetFromBase64(string input)
Parameters
inputstring
SetImage(LoadedImageSource)
Do not call this directly, use InstancedBitmap prop
protected virtual LoadedImageSource SetImage(LoadedImageSource loaded)
Parameters
loadedLoadedImageSource
Returns
SetImageInternal(SKImage, bool)
public LoadedImageSource SetImageInternal(SKImage image, bool protectFromDispose = false)
Parameters
Returns
SetImageSource(ImageSource)
public virtual void SetImageSource(ImageSource source)
Parameters
sourceImageSource
SetMeasuredAsEmpty(float)
protected override ScaledSize SetMeasuredAsEmpty(float scale)
Parameters
scalefloat
Returns
SetSource(ImageSource)
public void SetSource(ImageSource source)
Parameters
sourceImageSource
SetSource(Func<CancellationToken, Task<Stream>>)
public void SetSource(Func<CancellationToken, Task<Stream>> getStream)
Parameters
getStreamFunc<CancellationToken, Task<Stream>>
SetSource(string)
public void SetSource(string source)
Parameters
sourcestring
StopLoading()
public virtual void StopLoading()
SubscribeToCanReload()
protected virtual void SubscribeToCanReload()
SwapSources(float)
returns whether should abort pipeline
protected virtual bool SwapSources(float scale)
Parameters
scalefloat
Returns
Events
Cleared
public event EventHandler Cleared
Event Type
DisplayRectChanged
public event EventHandler<SKRect> DisplayRectChanged
Event Type
Error
public event EventHandler<ContentLoadedEventArgs> Error
Event Type
Success
public event EventHandler<ContentLoadedEventArgs> Success