Skip to content

Update SkiaSharp adapter to non-obsolete DrawBitmap overloads#2580

Open
raffaeler with Copilot wants to merge 3 commits into
mainfrom
copilot/dotnet-iot-2577-fix-obsolete-drawbitmap
Open

Update SkiaSharp adapter to non-obsolete DrawBitmap overloads#2580
raffaeler with Copilot wants to merge 3 commits into
mainfrom
copilot/dotnet-iot-2577-fix-obsolete-drawbitmap

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

SkiaSharp v4 obsoletes the SKCanvas.DrawBitmap overloads used by the SkiaSharp adapter, which blocks upgrading the package. This change switches the adapter to the supported SKSamplingOptions-based overloads.

  • What changed

    • Replaced point-based DrawBitmap calls with the corresponding overloads that accept SKSamplingOptions.
    • Updated rectangle-based DrawBitmap calls to the non-obsolete overloads as well.
    • Used SKSamplingOptions.Default to preserve the existing rendering behavior as closely as possible.
  • Affected paths

    • src/devices/SkiaSharpAdapter/SkiaSharpGraphicsExtensions.cs
  • Example

    targetCanvas.DrawBitmap(sourceBmp.WrappedBitmap, x, y, SKSamplingOptions.Default, null);
  • Scope

    • Covers all obsolete DrawBitmap usages in the SkiaSharp adapter, not just the float, float overload that surfaced first during compilation.

Copilot AI linked an issue Jul 1, 2026 that may be closed by this pull request
@dotnet-policy-service dotnet-policy-service Bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Jul 1, 2026
Copilot AI changed the title [WIP] Fix obsolete DrawBitmap overload in Skiasharp Update SkiaSharp adapter to non-obsolete DrawBitmap overloads Jul 1, 2026
Copilot AI requested a review from raffaeler July 1, 2026 06:44
@raffaeler

Copy link
Copy Markdown
Contributor

@copilot Your fix cannot work if you do not also migrate the Skia packages to the latest major version. The code you committed does not actually compile.

@raffaeler raffaeler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you committed requires Skia V4

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Your fix cannot work if you do not also migrate the Skia packages to the latest major version. The code you committed does not actually compile.

Addressed in e8eeeee. Both SkiaSharp adapter project files now reference SkiaSharp 4.148.0 / SkiaSharp.NativeAssets.Linux 4.148.0 so the SKSamplingOptions-based API changes compile against the package line used by the repo.

Copilot AI requested a review from raffaeler July 1, 2026 07:05
@raffaeler

Copy link
Copy Markdown
Contributor

@pgrawehr The changes are minimal. I would merge them. What do you think?

@raffaeler raffaeler marked this pull request as ready for review July 1, 2026 08:22
Copilot AI review requested due to automatic review settings July 1, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the SkiaSharp adapter to use SkiaSharp v4-supported SKCanvas.DrawBitmap overloads (with SKSamplingOptions) so the adapter can move off obsolete APIs and unblock a SkiaSharp package upgrade.

Changes:

  • Upgraded SkiaSharp and SkiaSharp.NativeAssets.Linux package references to 4.148.0 for the adapter projects.
  • Replaced obsolete DrawBitmap overload usages with SKSamplingOptions-based overloads, using SKSamplingOptions.Default to preserve existing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Iot.Device.Bindings.SkiaSharpAdapter/Iot.Device.Bindings.SkiaSharpAdapter.csproj Bumps SkiaSharp dependencies for the packable adapter package.
src/devices/SkiaSharpAdapter/SkiaSharpGraphicsExtensions.cs Updates DrawBitmap calls to non-obsolete SKSamplingOptions overloads.
src/devices/SkiaSharpAdapter/SkiaSharpAdapter.csproj Bumps SkiaSharp dependencies for the device-level adapter project.

Comment on lines 20 to 25
<ProjectReference Include="..\Iot.Device.Bindings\Iot.Device.Bindings.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
<PackageReference Include="SkiaSharp" Version="3.119.2" />
<PackageReference Include="SkiaSharp" Version="4.148.0" />
<!-- The NativeAssets packages for Windows and MacOS are included in the above by default -->
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="4.148.0" />
<Content Include="$(RepoRoot)src/devices/README-nuget.md" Pack="true" Visible="false" PackagePath="\README.md" />
@pgrawehr

pgrawehr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@pgrawehr The changes are minimal. I would merge them. What do you think?

I will do a verification hopefully soonish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skiasharp version 4 obsoleted DrawBitmap

4 participants