Skip to content

Commit ded7ddf

Browse files
authored
Remove image sharp (dotnet#2069)
* Create new SkiaSharpAdapter project This is an adapter that uses SkiaSharp as Bitmap handling backend * Create new image abstraction layer BitmapImage is the new abstract bitmap type. Changed most bindings to use the new type, and also changed bindings to use System.Drawing again for those types that will still be supported on all platforms (Color, Size, Rectangle, Point) * Disable warnings to make intermediate version build * Make test compile temporarily
1 parent 38f0478 commit ded7ddf

File tree

90 files changed

+2091
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2091
-324
lines changed

build.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<!-- Run Pack -->
3636
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\Iot.Device.Bindings\Iot.Device.Bindings.csproj" />
3737
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\System.Device.Gpio\System.Device.Gpio.csproj" />
38+
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\Iot.Device.Bindings.SkiaSharpAdapter\Iot.Device.Bindings.SkiaSharpAdapter.csproj" />
3839

3940
<ProjectReference Condition="'$(BuildPackages)' == 'true'" Include="@(_ProjectsToPackage)" Targets="Pack" />
4041
</ItemGroup>

eng/Versions.external.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<!-- These references to third-party libraries are included in all projects except System.Device.Gpio and the build wrapper project -->
33
<ItemGroup Condition="'$(MSBuildProjectName)' != 'System.Device.Gpio' And '$(MSBuildProjectName)' != 'build'">
44
<PackageReference Include="UnitsNet" Version="5.1.0" />
5-
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
65
</ItemGroup>
76

87
<!-- Automatically include these assemblies in all test projects -->

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<PreReleaseVersionLabel>prerelease</PreReleaseVersionLabel>
77
<MicrosoftDotNetGenAPIPackageVersion>7.0.0-beta.23211.2</MicrosoftDotNetGenAPIPackageVersion>
88
<!-- dotnet/corefx dependencies -->
9-
<SystemDrawingCommonPackageVersion>5.0.3</SystemDrawingCommonPackageVersion>
9+
<SystemDrawingCommonPackageVersion>6.0.0</SystemDrawingCommonPackageVersion>
1010
<SystemIOPortsPackageVersion>5.0.1</SystemIOPortsPackageVersion>
1111
<MicrosoftWin32RegistryPackageVersion>5.0.0</MicrosoftWin32RegistryPackageVersion>
1212
<SystemRuntimeWindowsRuntimePackageVersion>4.6.0</SystemRuntimeWindowsRuntimePackageVersion>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<!-- Packaging related properties -->
3+
<PropertyGroup>
4+
<MajorVersion>2</MajorVersion>
5+
<MinorVersion>3</MinorVersion>
6+
<Description>This package contains the BitmapImage adapter using SkiaSharp. This library is an optional package to provide imaging functionality for Iot.Device.Bidnings.dll</Description>
7+
<PackageTags>.NET Core IoT Device Bindings SkiaSharp Adapter</PackageTags>
8+
<EnablePackageValidation>false</EnablePackageValidation>
9+
<PackageValidationBaselineVersion>2.2.0</PackageValidationBaselineVersion>
10+
</PropertyGroup>
11+
12+
<Import Project="../../Directory.Build.props" />
13+
</Project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
5+
<LangVersion>10</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<EnableDefaultItems>true</EnableDefaultItems>
9+
<IsPackable>true</IsPackable>
10+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
11+
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
12+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage)</TargetsForTfmSpecificContentInPackage>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<Compile Include="../devices/SkiaSharpAdapter/*.cs" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\Iot.Device.Bindings\Iot.Device.Bindings.csproj" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
22+
<PackageReference Include="SkiaSharp" Version="2.88.3" />
23+
<!-- The NativeAssets packages for Windows and MacOS are included in the above by default -->
24+
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
25+
</ItemGroup>
26+
27+
28+
</Project>

src/Iot.Device.Bindings/CompatibilitySuppressions.xml

Lines changed: 750 additions & 36 deletions
Large diffs are not rendered by default.

src/Iot.Device.Bindings/Iot.Device.Bindings.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<!-- Excluding samples and test projects when getting source files -->
2323
<_ExcludeProjectReferences Include="$(DeviceRoot)**/samples/**/*.csproj" />
2424
<_ExcludeProjectReferences Include="$(DeviceRoot)**/tests/**/*.csproj" />
25+
<_ExcludeProjectReferences Include="$(DeviceRoot)SkiaSharpAdapter/*.csproj" />
2526
</ItemGroup>
2627

2728
<!-- The following ItemGroup is in charge of getting the source files we will compile on each TFM -->
@@ -30,12 +31,13 @@
3031
</ItemGroup>
3132

3233
<ItemGroup>
33-
<PackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommonPackageVersion)" />
3434
<PackageReference Include="System.IO.Ports" Version="$(SystemIOPortsPackageVersion)" />
3535
<ProjectReference Include="$(MainLibraryPath)System.Device.Gpio.csproj" />
3636
<PackageReference Include="System.Management" Version="$(SystemManagementPackageVersion)" />
3737
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
3838
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonPackageVersion)" />
39+
<!-- This package is only used for windows specific stuff. -->
40+
<PackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommonPackageVersion)" />
3941
</ItemGroup>
4042
<ItemGroup Condition="$(TargetFramework) == 'netstandard2.0'">
4143
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />

src/devices/Arduino/samples/ApiChecker/Arduino.sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFrameworks>$(DefaultBindingTfms)</TargetFrameworks>
4+
<TargetFrameworks>$(DefaultSampleTfms)</TargetFrameworks>
55
<RootNamespace>Iot.Device.Arduino.Sample</RootNamespace>
66
<EnableDefaultItems>false</EnableDefaultItems>
77
<AssemblyName>Arduino.sample</AssemblyName>

src/devices/Arduino/samples/ApiChecker/RgbLedTest.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Drawing;
67
using System.Linq;
78
using System.Text;
89
using System.Threading.Tasks;
9-
using SixLabors.ImageSharp.ColorSpaces;
10-
using SixLabors.ImageSharp.ColorSpaces.Conversion;
1110
using static System.Threading.Thread;
1211

1312
namespace Iot.Device.Arduino.Sample
@@ -47,7 +46,6 @@ public void DoTest()
4746
redChannel.DutyCycle = 0;
4847
Sleep(1000);
4948

50-
var converter = new ColorSpaceConverter();
5149
float angle = 0.0f;
5250
float hv = 1.0f;
5351
float hvDelta = 0; // 0.001f;
@@ -57,8 +55,7 @@ public void DoTest()
5755
float blueCorrection = 0.95f;
5856
while (!Console.KeyAvailable)
5957
{
60-
var hsv = new Hsv(angle, 1.0f, 1.0f);
61-
var rgb = converter.ToRgb(hsv);
58+
Color rgb = Color.Blue;
6259
redChannel.DutyCycle = rgb.R;
6360
blueChannel.DutyCycle = rgb.B * blueCorrection;
6461
greenChannel.DutyCycle = rgb.G * greenCorrection;

src/devices/BuildHat/Brick.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
using System.Data;
77
using System.Device.Gpio;
88
using System.Diagnostics;
9+
using System.Drawing;
910
using System.Globalization;
1011
using System.IO;
1112
using System.IO.Ports;
1213
using System.Linq;
1314
using System.Reflection;
1415
using System.Text;
1516
using System.Threading;
16-
using BuildHat.Models;
1717
using Iot.Device.BuildHat.Models;
1818
using Iot.Device.BuildHat.Motors;
1919
using Iot.Device.BuildHat.Sensors;
2020
using Iot.Device.Common;
2121
using Microsoft.Extensions.Logging;
22-
using SixLabors.ImageSharp;
2322
using UnitsNet;
2423

2524
namespace Iot.Device.BuildHat
@@ -1159,10 +1158,12 @@ private void ProcessOutput(string line)
11591158
case 5:
11601159
if (_sensorType[port] == SensorType.SpikePrimeColorSensor)
11611160
{
1162-
color.Color = Color.FromRgba((byte)(Convert.ToInt32(elements[inc++]) * 255 / 1024),
1163-
(byte)(Convert.ToInt32(elements[inc++]) * 255 / 1024),
1164-
(byte)(Convert.ToInt32(elements[inc++]) * 255 / 1024),
1165-
(byte)(Convert.ToInt32(elements[inc++]) * 255 / 1024));
1161+
// Verify the colors here (a and b could be exchanged)
1162+
color.Color = Color.FromArgb((byte)(Convert.ToInt32(elements[inc + 3]) * 255 / 1024),
1163+
(byte)(Convert.ToInt32(elements[inc + 1]) * 255 / 1024),
1164+
(byte)(Convert.ToInt32(elements[inc + 2]) * 255 / 1024),
1165+
(byte)(Convert.ToInt32(elements[inc + 0]) * 255 / 1024));
1166+
inc += 4;
11661167
color.IsColorDetected = true;
11671168
}
11681169
else
@@ -1186,7 +1187,7 @@ private void ProcessOutput(string line)
11861187
// Normal color mode
11871188
if (!isCombi)
11881189
{
1189-
color.Color = Color.FromRgb((byte)(Convert.ToInt32(elements[inc++]) * 255 / 400),
1190+
color.Color = Color.FromArgb((byte)(Convert.ToInt32(elements[inc++]) * 255 / 400),
11901191
(byte)(Convert.ToInt32(elements[inc++]) * 255 / 400),
11911192
(byte)(Convert.ToInt32(elements[inc++]) * 255 / 400));
11921193
color.IsColorDetected = true;

0 commit comments

Comments
 (0)