| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Linq;
 
- using Avalonia.Controls.Platform.Surfaces;
 
- using Avalonia.Media;
 
- using Avalonia.Platform;
 
- using SkiaSharp;
 
- namespace Avalonia.Skia
 
- {
 
-     public partial class PlatformRenderInterface : IPlatformRenderInterface
 
-     {
 
-         public IBitmapImpl CreateBitmap(int width, int height)
 
-         {
 
-             return CreateRenderTargetBitmap(width, height, 96, 96);
 
-         }
 
-         public IFormattedTextImpl CreateFormattedText(
 
-             string text,
 
-             Typeface typeface,
 
-             TextAlignment textAlignment,
 
-             TextWrapping wrapping,
 
-             Size constraint,
 
-             IReadOnlyList<FormattedTextStyleSpan> spans)
 
-         {
 
-             return new FormattedTextImpl(text, typeface, textAlignment, wrapping, constraint, spans);
 
-         }
 
-         public IStreamGeometryImpl CreateStreamGeometry()
 
-         {
 
-             return new StreamGeometryImpl();
 
-         }
 
-         public IBitmapImpl LoadBitmap(System.IO.Stream stream)
 
-         {
 
-             using (var s = new SKManagedStream(stream))
 
-             {
 
-                 var bitmap = SKBitmap.Decode(s);
 
-                 if (bitmap != null)
 
-                 {
 
-                     return new BitmapImpl(bitmap);
 
-                 }
 
-                 else
 
-                 {
 
-                     throw new ArgumentException("Unable to load bitmap from provided data");
 
-                 }
 
-             }
 
-         }
 
-         public IBitmapImpl LoadBitmap(string fileName)
 
-         {
 
-             using (var stream = File.OpenRead(fileName))
 
-             {
 
-                 return LoadBitmap(stream);
 
-             }
 
-         }
 
-         public IBitmapImpl LoadBitmap(PixelFormat format, IntPtr data, int width, int height, int stride)
 
-         {
 
-             using (var tmp = new SKBitmap())
 
-             {
 
-                 tmp.InstallPixels(new SKImageInfo(width, height, format.ToSkColorType(), SKAlphaType.Premul)
 
-                     , data, stride);
 
-                 return new BitmapImpl(tmp.Copy());
 
-             }
 
-         }
 
-         public IRenderTargetBitmapImpl CreateRenderTargetBitmap(
 
-             int width,
 
-             int height,
 
-             double dpiX,
 
-             double dpiY)
 
-         {
 
-             if (width < 1)
 
-                 throw new ArgumentException("Width can't be less than 1", nameof(width));
 
-             if (height < 1)
 
-                 throw new ArgumentException("Height can't be less than 1", nameof(height));
 
-             return new BitmapImpl(width, height);
 
-         }
 
-         public virtual IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces)
 
-         {
 
-             var fb = surfaces?.OfType<IFramebufferPlatformSurface>().FirstOrDefault();
 
-             if (fb == null)
 
-                 throw new Exception("Skia backend currently only supports framebuffer render target");
 
-             return new FramebufferRenderTarget(fb);
 
-         }
 
-         public IWritableBitmapImpl CreateWritableBitmap(int width, int height, PixelFormat? format = null)
 
-         {
 
-             return new BitmapImpl(width, height, format);
 
-         }
 
-     }
 
- }
 
 
  |