[PR #394] Implement NativeImage support, fixes #14 #1157

Open
opened 2026-01-29 16:57:53 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/ElectronNET/Electron.NET/pull/394

State: closed
Merged: Yes


This is a long time running of reading documentation and source code within Electron/Chromium itself to see how the image handling is implemented.

The main conversion that happens in this bridge is that we have an array of (float)scaleFactor=>System.Drawing.Image. We serialize these by creating a json object with the scaleFactor as the key, and a base64 encoded representation of the System.Drawing.Image. From there, we send over the serialized data. The javascript picks it up and creates an empty nativeImage. Then, we add all the representations with scale factor to the electron nativeImage.

Everything image manipulation-wise happens on the dotnet side. The only thing this is currently used for with the bridge is clipboard image reading/writing. Hopefully we can add NativeImage support to more things soon, such as Tray Icons, etc.

**Original Pull Request:** https://github.com/ElectronNET/Electron.NET/pull/394 **State:** closed **Merged:** Yes --- This is a long time running of reading documentation and source code within Electron/Chromium itself to see how the image handling is implemented. The main conversion that happens in this bridge is that we have an array of (float)scaleFactor=>System.Drawing.Image. We serialize these by creating a json object with the scaleFactor as the key, and a base64 encoded representation of the System.Drawing.Image. From there, we send over the serialized data. The javascript picks it up and creates an empty nativeImage. Then, we add all the representations with scale factor to the electron nativeImage. Everything image manipulation-wise happens on the dotnet side. The only thing this is currently used for with the bridge is clipboard image reading/writing. Hopefully we can add NativeImage support to more things soon, such as Tray Icons, etc.
claunia added the pull-request label 2026-01-29 16:57:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1157