Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.9.5 #137

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions dev/github_uploadnugets.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dev/nuget_uploadnugets.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.5" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.5" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.5" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.5" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.5" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<PropertyGroup Condition="'$(UseSkiaSharp3)' != 'true'">
<PackageReleaseNotes>Using SkiaSharp 2.xx. Checkout the DrawnUi Sandbox project for usage example.</PackageReleaseNotes>
<Version>1.2.9.4</Version>
<Version>1.2.9.5</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(UseSkiaSharp3)' == 'true'">
Expand Down
33 changes: 18 additions & 15 deletions src/Engine/Features/Images/SkiaImageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,28 @@ public virtual Task<SKBitmap> LoadImageManagedAsync(ImageSource source, Cancella
// 1 Try to get from cache
var cacheKey = uri;

var cachedBitmap = _cachingProvider.Get<SKBitmap>(cacheKey);
if (cachedBitmap.HasValue)
if (!string.IsNullOrEmpty(cacheKey))
{
if (ReuseBitmaps)
var cachedBitmap = _cachingProvider.Get<SKBitmap>(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}");

Expand Down
3 changes: 2 additions & 1 deletion src/Engine/Internals/Xaml/NotConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
{
return value;
}
}
}

16 changes: 3 additions & 13 deletions src/Engine/Platforms/Windows/SkiaImageManager.Windows.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -145,12 +135,12 @@ public static async Task<SKBitmap> LoadImageOnPlatformAsync(ImageSource source,
}
catch (Exception e)
{
SkiaImageManager.TraceLog($"[LoadImageOnPlatformAsync] {e}");
Super.Log($"[LoadImageOnPlatformAsync] {e}");
}

return null;
}



}
}
4 changes: 3 additions & 1 deletion src/samples/Sandbox/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand All @@ -13,6 +14,7 @@
</ResourceDictionary.MergedDictionaries>

<xaml:NotConverter x:Key="NotConverter" />
<toolkit:ByteArrayToImageSourceConverter x:Key="ByteArrayToImageSourceConverter" />

</ResourceDictionary>
</Application.Resources>
Expand Down
69 changes: 6 additions & 63 deletions src/samples/Sandbox/MainPageDevShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,76 +47,19 @@ void Build()
HorizontalOptions = LayoutOptions.Fill,
Children = new List<SkiaControl>()
{
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<SkiaShadow>()
{

},
Points = new List<SkiaPoint>()
{
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<SkiaPoint>()
{
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<SkiaPoint>()
{
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)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/samples/Sandbox/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
global using DrawnUi.Maui.Draw;
global using SkiaSharp;
using CommunityToolkit.Maui;
using Microsoft.Extensions.Logging;

namespace Sandbox
Expand Down Expand Up @@ -30,6 +31,7 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down
1 change: 1 addition & 0 deletions src/samples/Sandbox/Sandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

Expand Down
38 changes: 7 additions & 31 deletions src/samples/Sandbox/TestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<Grid
Expand All @@ -28,37 +28,13 @@
Tag="Wrapper"
VerticalOptions="Fill">

<draw:SkiaLabel
DropShadowColor="#33333333"
DropShadowSize="4"
FontFamily="FontTextTitle"
FontSize="44"
<draw:SkiaImage
Aspect="AspectFit"
HeightRequest="200"
HorizontalOptions="Center"
StrokeColor="White"
StrokeWidth="2"
Text="Sandbox"
UseCache="None"
VerticalOptions="Center">
<draw:SkiaLabel.FillGradient>

<draw:SkiaGradient
EndXRatio="0"
EndYRatio="1"
StartXRatio="0"
StartYRatio="0"
Type="Linear">
<draw:SkiaGradient.Colors>
<Color>White</Color>
<Color>Yellow</Color>
<Color>Orange</Color>
<Color>Red</Color>
<Color>DarkRed</Color>
</draw:SkiaGradient.Colors>
</draw:SkiaGradient>

</draw:SkiaLabel.FillGradient>
</draw:SkiaLabel>

SemanticProperties.Description="Image"
Source="{Binding Source={x:Reference ThisPage}, Path=ImageBytes, Converter={StaticResource ByteArrayToImageSourceConverter}}"
WidthRequest="200" />

<!--<draw:SkiaShape
BackgroundColor="White"
Expand Down
22 changes: 21 additions & 1 deletion src/samples/Sandbox/TestPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,28 @@ public TestPage()
}
}

public byte[] ImageBytes
{
get
{
try
{
using var stream = FileSystem.OpenAppPackageFileAsync("Images/logo.png").GetAwaiter().GetResult();
using var ms = new MemoryStream();
stream.CopyTo(ms);
return ms.ToArray();
}
catch (Exception e)
{
Console.WriteLine(e);
}

return null;
}
}





}
}
Loading