SkiaExtensions.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="SkiaExtensions.cs" company="OxyPlot">
  3. // Copyright (c) 2020 OxyPlot contributors
  4. // </copyright>
  5. // --------------------------------------------------------------------------------------------------------------------
  6. namespace OxyPlot.SkiaSharp
  7. {
  8. using global::SkiaSharp;
  9. /// <summary>
  10. /// Provides extension methods for conversion between SkiaSharp and oxyplot objects.
  11. /// </summary>
  12. public static class SkiaExtensions
  13. {
  14. /// <summary>
  15. /// Converts a <see cref="OxyColor"/> to a <see cref="SKColor"/>;
  16. /// </summary>
  17. /// <param name="color">The <see cref="OxyColor"/>.</param>
  18. /// <returns>The <see cref="SKColor"/>.</returns>
  19. public static OxyColor ToOxyColor(this SKColor color)
  20. {
  21. return OxyColor.FromArgb(color.Alpha, color.Red, color.Green, color.Blue);
  22. }
  23. /// <summary>
  24. /// Converts a <see cref="SKColor"/> to a <see cref="OxyColor"/>;
  25. /// </summary>
  26. /// <param name="color">The <see cref="SKColor"/>.</param>
  27. /// <returns>The <see cref="OxyColor"/>.</returns>
  28. public static SKColor ToSKColor(this OxyColor color)
  29. {
  30. return new SKColor(color.R, color.G, color.B, color.A);
  31. }
  32. }
  33. }