[PR #394] [MERGED] Implement NativeImage support, fixes #14 #1155

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

📋 Pull Request Information

Original PR: https://github.com/ElectronNET/Electron.NET/pull/394
Author: @zacbre
Created: 5/7/2020
Status: Merged
Merged: 5/9/2020
Merged by: @GregorBiswanger

Base: masterHead: master


📝 Commits (8)

  • 7daac2d Add NativeImage support, clipboard image read/write.
  • 23015a9 Add System.Drawing.Common reference.
  • e67f6c5 Merge remote-tracking branch 'upstream/master'
  • e295558 Fix MenusController.cs
  • 9b27075 Add full NativeImage support for Electron.NET
  • fa51cdd Merge remote-tracking branch 'upstream/master'
  • b87d7f9 Add XML comments
  • c9f0c43 Remove using Clipboard

📊 Changes

17 files changed (+915 additions, -110 deletions)

View changed files

📝 ElectronNET.API/Clipboard.cs (+34 -0)
📝 ElectronNET.API/ElectronNET.API.csproj (+1 -0)
ElectronNET.API/Entities/AddRepresentationOptions.cs (+33 -0)
ElectronNET.API/Entities/BitmapOptions.cs (+13 -0)
ElectronNET.API/Entities/CreateFromBitmapOptions.cs (+23 -0)
ElectronNET.API/Entities/CreateFromBufferOptions.cs (+23 -0)
📝 ElectronNET.API/Entities/NativeImage.cs (+446 -102)
ElectronNET.API/Entities/NativeImageJsonConverter.cs (+34 -0)
ElectronNET.API/Entities/ResizeOptions.cs (+23 -0)
ElectronNET.API/Entities/ToBitmapOptions.cs (+13 -0)
ElectronNET.API/Entities/ToDataUrlOptions.cs (+13 -0)
ElectronNET.API/Entities/ToPNGOptions.cs (+13 -0)
📝 ElectronNET.Host/api/clipboard.js (+16 -0)
📝 ElectronNET.Host/api/clipboard.ts (+19 -1)
📝 ElectronNET.WebApp/Controllers/ClipboardController.cs (+19 -1)
📝 ElectronNET.WebApp/Views/Clipboard/Index.cshtml (+188 -6)
📝 ElectronNET.WebApp/wwwroot/assets/css/demo.css (+4 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ElectronNET/Electron.NET/pull/394 **Author:** [@zacbre](https://github.com/zacbre) **Created:** 5/7/2020 **Status:** ✅ Merged **Merged:** 5/9/2020 **Merged by:** [@GregorBiswanger](https://github.com/GregorBiswanger) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (8) - [`7daac2d`](https://github.com/ElectronNET/Electron.NET/commit/7daac2d04ee6b974d50390d4a6bf6fcb4ed0855e) Add NativeImage support, clipboard image read/write. - [`23015a9`](https://github.com/ElectronNET/Electron.NET/commit/23015a9f3d43082c087cb780d5fb9aeadd17cd16) Add System.Drawing.Common reference. - [`e67f6c5`](https://github.com/ElectronNET/Electron.NET/commit/e67f6c500b11158a417d27c1a9cded79500a792a) Merge remote-tracking branch 'upstream/master' - [`e295558`](https://github.com/ElectronNET/Electron.NET/commit/e295558258aad9ad4f5e0491a1fc37d5059822d2) Fix MenusController.cs - [`9b27075`](https://github.com/ElectronNET/Electron.NET/commit/9b270755d041debb34362eca1b2c75e82b48bf19) Add full NativeImage support for Electron.NET - [`fa51cdd`](https://github.com/ElectronNET/Electron.NET/commit/fa51cdd72cda82c39950e723876c566012f75095) Merge remote-tracking branch 'upstream/master' - [`b87d7f9`](https://github.com/ElectronNET/Electron.NET/commit/b87d7f98995c8dfe94a749fc295a42aad2ad6a27) Add XML comments - [`c9f0c43`](https://github.com/ElectronNET/Electron.NET/commit/c9f0c43bc90f2b82412600b26719ed3d6e35b0a7) Remove using Clipboard ### 📊 Changes **17 files changed** (+915 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `ElectronNET.API/Clipboard.cs` (+34 -0) 📝 `ElectronNET.API/ElectronNET.API.csproj` (+1 -0) ➕ `ElectronNET.API/Entities/AddRepresentationOptions.cs` (+33 -0) ➕ `ElectronNET.API/Entities/BitmapOptions.cs` (+13 -0) ➕ `ElectronNET.API/Entities/CreateFromBitmapOptions.cs` (+23 -0) ➕ `ElectronNET.API/Entities/CreateFromBufferOptions.cs` (+23 -0) 📝 `ElectronNET.API/Entities/NativeImage.cs` (+446 -102) ➕ `ElectronNET.API/Entities/NativeImageJsonConverter.cs` (+34 -0) ➕ `ElectronNET.API/Entities/ResizeOptions.cs` (+23 -0) ➕ `ElectronNET.API/Entities/ToBitmapOptions.cs` (+13 -0) ➕ `ElectronNET.API/Entities/ToDataUrlOptions.cs` (+13 -0) ➕ `ElectronNET.API/Entities/ToPNGOptions.cs` (+13 -0) 📝 `ElectronNET.Host/api/clipboard.js` (+16 -0) 📝 `ElectronNET.Host/api/clipboard.ts` (+19 -1) 📝 `ElectronNET.WebApp/Controllers/ClipboardController.cs` (+19 -1) 📝 `ElectronNET.WebApp/Views/Clipboard/Index.cshtml` (+188 -6) 📝 `ElectronNET.WebApp/wwwroot/assets/css/demo.css` (+4 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 16:57:52 +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#1155