diff --git a/README.md b/README.md index 20343c54..14ba9276 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,10 @@ V3 preview: subclassed `SkiaShaderEffect`, implementing `ISkiaGestureProcessor`, ## What's New -### Nuget 1.2.9.4 +### Nuget 1.2.9.5 for SkiaSharp 2.88.9-preview.2.2 +* [HotFix](https://github.com/taublast/DrawnUi.Maui/issues/136) for loading images from StreamImageSource * SkiaShape new Types: Polygon and Line. New property for their Points: Smooth (0-1) to smooth angles. * Shapes demo page inside SandBox project. * VisualElement Shadow property now supported everywhere as an optional addition to existing shadows. diff --git a/dev/github_uploadnugets.bat b/dev/github_uploadnugets.bat index b34e6ae1..cdcd1ce3 100644 --- a/dev/github_uploadnugets.bat +++ b/dev/github_uploadnugets.bat @@ -13,8 +13,8 @@ REM Define the source directory for the packages set "source_dir=E:\Nugets" REM Define the list of file masks for the packages -set "mask[1]=DrawnUi.Maui*.1.2.9.4*.nupkg" -set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.4*.*nupkg" +set "mask[1]=DrawnUi.Maui*.1.2.9.5*.nupkg" +set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.5*.*nupkg" set "mask_count=2" REM Loop through each file mask diff --git a/dev/nuget_uploadnugets.bat b/dev/nuget_uploadnugets.bat index f7511333..b0467cbc 100644 --- a/dev/nuget_uploadnugets.bat +++ b/dev/nuget_uploadnugets.bat @@ -13,8 +13,8 @@ REM Define the source directory for the packages set "source_dir=E:\Nugets" REM Define the list of file masks for the packages -set "mask[1]=DrawnUi.Maui*.1.2.9.4*.nupkg" -set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.4*.*nupkg" +set "mask[1]=DrawnUi.Maui*.1.2.9.5*.nupkg" +set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.5*.*nupkg" set "mask_count=2" REM Loop through each file mask diff --git a/src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj b/src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj index 0b2fb24c..cde83475 100644 --- a/src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj +++ b/src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj @@ -44,7 +44,7 @@ - + \ No newline at end of file diff --git a/src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj b/src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj index b3f84001..ba0300b3 100644 --- a/src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj +++ b/src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj @@ -42,7 +42,7 @@ - + diff --git a/src/Addons/DrawnUi.Maui.MapsUi/src/DrawnUi.Maui.MapsUi.csproj b/src/Addons/DrawnUi.Maui.MapsUi/src/DrawnUi.Maui.MapsUi.csproj index b43dc124..fe38839a 100644 --- a/src/Addons/DrawnUi.Maui.MapsUi/src/DrawnUi.Maui.MapsUi.csproj +++ b/src/Addons/DrawnUi.Maui.MapsUi/src/DrawnUi.Maui.MapsUi.csproj @@ -54,7 +54,7 @@ - + diff --git a/src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj b/src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj index 6db77439..826398b3 100644 --- a/src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj +++ b/src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj @@ -47,7 +47,7 @@ - + diff --git a/src/Addons/DrawnUi.MauiGraphics/DrawnUi.MauiGraphics.csproj b/src/Addons/DrawnUi.MauiGraphics/DrawnUi.MauiGraphics.csproj index be0af46e..81eeec6f 100644 --- a/src/Addons/DrawnUi.MauiGraphics/DrawnUi.MauiGraphics.csproj +++ b/src/Addons/DrawnUi.MauiGraphics/DrawnUi.MauiGraphics.csproj @@ -41,7 +41,7 @@ - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index bb1a9409..9e1fd5ab 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,7 @@ Using SkiaSharp 2.xx. Checkout the DrawnUi Sandbox project for usage example. - 1.2.9.4 + 1.2.9.5 diff --git a/src/Engine/Features/Images/SkiaImageManager.cs b/src/Engine/Features/Images/SkiaImageManager.cs index d4596b4e..7978c2cd 100644 --- a/src/Engine/Features/Images/SkiaImageManager.cs +++ b/src/Engine/Features/Images/SkiaImageManager.cs @@ -319,25 +319,28 @@ public virtual Task LoadImageManagedAsync(ImageSource source, Cancella // 1 Try to get from cache var cacheKey = uri; - var cachedBitmap = _cachingProvider.Get(cacheKey); - if (cachedBitmap.HasValue) + if (!string.IsNullOrEmpty(cacheKey)) { - if (ReuseBitmaps) + var cachedBitmap = _cachingProvider.Get(cacheKey); + if (cachedBitmap.HasValue) { - tcs.TrySetResult(cachedBitmap.Value); - } - else - { - tcs.TrySetResult(cachedBitmap.Value.Copy()); - } - TraceLog($"ImageLoadManager: Returning cached bitmap for UriImageSource {uri}"); + if (ReuseBitmaps) + { + tcs.TrySetResult(cachedBitmap.Value); + } + else + { + tcs.TrySetResult(cachedBitmap.Value.Copy()); + } + TraceLog($"ImageLoadManager: Returning cached bitmap for UriImageSource {uri}"); - //if (pendingLoads.Any(x => x.Value.Count != 0)) - //{ - // RunProcessQueue(); - //} + //if (pendingLoads.Any(x => x.Value.Count != 0)) + //{ + // RunProcessQueue(); + //} - return tcs.Task; + return tcs.Task; + } } TraceLog($"ImageLoadManager: Not found cached UriImageSource {uri}"); diff --git a/src/Engine/Internals/Xaml/NotConverter.cs b/src/Engine/Internals/Xaml/NotConverter.cs index 1b647edb..cd0519ee 100644 --- a/src/Engine/Internals/Xaml/NotConverter.cs +++ b/src/Engine/Internals/Xaml/NotConverter.cs @@ -13,4 +13,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu { return value; } -} \ No newline at end of file +} + diff --git a/src/Engine/Platforms/Windows/SkiaImageManager.Windows.cs b/src/Engine/Platforms/Windows/SkiaImageManager.Windows.cs index c40ff0ce..73bc181d 100644 --- a/src/Engine/Platforms/Windows/SkiaImageManager.Windows.cs +++ b/src/Engine/Platforms/Windows/SkiaImageManager.Windows.cs @@ -1,14 +1,4 @@ -using Microsoft.Maui.Storage; -using Microsoft.UI.Xaml.Media.Imaging; -using SkiaSharp; -using System; -using System.Diagnostics; -using System.Net; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Security.Authentication; - - -namespace DrawnUi.Maui.Draw; +namespace DrawnUi.Maui.Draw; public partial class SkiaImageManager { @@ -145,7 +135,7 @@ public static async Task LoadImageOnPlatformAsync(ImageSource source, } catch (Exception e) { - SkiaImageManager.TraceLog($"[LoadImageOnPlatformAsync] {e}"); + Super.Log($"[LoadImageOnPlatformAsync] {e}"); } return null; @@ -153,4 +143,4 @@ public static async Task LoadImageOnPlatformAsync(ImageSource source, -} \ No newline at end of file +} diff --git a/src/samples/Sandbox/App.xaml b/src/samples/Sandbox/App.xaml index 952a7b2e..3638ba9f 100644 --- a/src/samples/Sandbox/App.xaml +++ b/src/samples/Sandbox/App.xaml @@ -3,7 +3,8 @@ x:Class="Sandbox.App" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" - xmlns:xaml="clr-namespace:DrawnUi.Maui.Infrastructure.Xaml;assembly=DrawnUi.Maui"> + xmlns:xaml="clr-namespace:DrawnUi.Maui.Infrastructure.Xaml;assembly=DrawnUi.Maui" + xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"> @@ -13,6 +14,7 @@ + diff --git a/src/samples/Sandbox/MainPageDevShape.cs b/src/samples/Sandbox/MainPageDevShape.cs index 3e0ef971..6afc5ab4 100644 --- a/src/samples/Sandbox/MainPageDevShape.cs +++ b/src/samples/Sandbox/MainPageDevShape.cs @@ -47,76 +47,19 @@ void Build() HorizontalOptions = LayoutOptions.Fill, Children = new List() { - new SkiaShape() - { - SmoothPoints = 0.9f, - VerticalOptions = LayoutOptions.Center, - HorizontalOptions = LayoutOptions.Center, - WidthRequest = 150, - HeightRequest = 150, - Type = ShapeType.Polygon, - StrokeColor = Colors.Black, - StrokeWidth = 3, - StrokeBlendMode = SKBlendMode.SrcIn, - StrokeCap = SKStrokeCap.Round, - Rotation = 0, - BackgroundColor = Colors.Yellow, - //Points = SkiaShape.CreateStarPoints(5, 0.5), - Shadows = new List() - { - }, - Points = new List() - { - new (0.1f, 0.1f), - new (0.9f, 0.1f), - new (0.8f, 0.9f), - new (0.1f, 0.9f), - }, - }, - new SkiaShape() - { - IsVisible = false, - Type = ShapeType.Line, - StrokeColor = Colors.Red, - StrokeWidth = 2, - HorizontalOptions = LayoutOptions.Fill, - VerticalOptions = LayoutOptions.Fill, - Points = new List() - { - new (0.2f, 0.8f), - new (0.8f, 0.2f), - new (1.0f, 0.2f), - }, - }, - new SkiaShape() - { - IsVisible = false, - SmoothPoints = 0.3f, - Type = ShapeType.Line, - StrokeColor = Colors.Green, - StrokeWidth = 2, - HorizontalOptions = LayoutOptions.Fill, - VerticalOptions = LayoutOptions.Fill, - Points = new List() - { - new (0.2f, 0.8f), - new (0.8f, 0.2f), - new (1.0f, 0.2f), - }, - }, new SkiaImage() { Source="car.png", - WidthRequest = 100, - HeightRequest = 100, + WidthRequest = 150, + HeightRequest = 150, VerticalOptions = LayoutOptions.End, - Margin = 10, + Margin = 24, Shadow = new Shadow() { - Radius = 3, - Brush= Colors.Black, - Offset = new (2,2) + Radius = 8, + Brush= Colors.Purple, + Offset = new (5,5) } } } diff --git a/src/samples/Sandbox/MauiProgram.cs b/src/samples/Sandbox/MauiProgram.cs index 9ab9c4f2..7e669479 100644 --- a/src/samples/Sandbox/MauiProgram.cs +++ b/src/samples/Sandbox/MauiProgram.cs @@ -1,5 +1,6 @@ global using DrawnUi.Maui.Draw; global using SkiaSharp; +using CommunityToolkit.Maui; using Microsoft.Extensions.Logging; namespace Sandbox @@ -30,6 +31,7 @@ public static MauiApp CreateMauiApp() var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() + .UseMauiCommunityToolkit() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); diff --git a/src/samples/Sandbox/Sandbox.csproj b/src/samples/Sandbox/Sandbox.csproj index e936bd60..93fc025b 100644 --- a/src/samples/Sandbox/Sandbox.csproj +++ b/src/samples/Sandbox/Sandbox.csproj @@ -193,6 +193,7 @@ + diff --git a/src/samples/Sandbox/TestPage.xaml b/src/samples/Sandbox/TestPage.xaml index 825cfeb4..2e6e1026 100644 --- a/src/samples/Sandbox/TestPage.xaml +++ b/src/samples/Sandbox/TestPage.xaml @@ -8,7 +8,7 @@ xmlns:generic="clr-namespace:System.Collections.Generic;assembly=System.Collections" xmlns:sandbox="clr-namespace:Sandbox" xmlns:views="clr-namespace:Sandbox.Views" - x:DataType="sandbox:MainPageViewModel" + x:Name="ThisPage" BackgroundColor="#000000"> - - - - - - White - Yellow - Orange - Red - DarkRed - - - - - - + SemanticProperties.Description="Image" + Source="{Binding Source={x:Reference ThisPage}, Path=ImageBytes, Converter={StaticResource ByteArrayToImageSourceConverter}}" + WidthRequest="200" />