Skip to content

Implement NativeImage support, fixes #14 #394

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

Merged
merged 8 commits into from
May 9, 2020

Conversation

zacbre
Copy link
Contributor

@zacbre zacbre commented May 6, 2020

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.

@GregorBiswanger GregorBiswanger self-assigned this May 6, 2020
@GregorBiswanger GregorBiswanger added this to the 8.31.2 milestone May 6, 2020
@GregorBiswanger
Copy link
Member

Wow! Thanks for your great work!

I will do a review as soon as possible and deliver it to our next update.

@GregorBiswanger
Copy link
Member

Do you have an idea why the build fails with Travis-CI?

@GregorBiswanger
Copy link
Member

Did you bring everything together on the basis of Electron.NET 8.31.1?

@GregorBiswanger GregorBiswanger merged commit 6f1f7cb into ElectronNET:master May 9, 2020
Copy link
Member

@GregorBiswanger GregorBiswanger left a comment

Choose a reason for hiding this comment

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

I test it with the Demo App, but it dosn´t work.

electron-net-copy-paste-image

@zacbre
Copy link
Contributor Author

zacbre commented May 11, 2020

Hi Gregor, let me look into why the demo app is not working for you.
I made sure to delete my nuget package cache, so it was up to date with the latest built package.

I just pulled upstream master, and ran the app, and it seemed to work for me. The box next to copy is for pasting images into, i.e ctrl+v.

I've attached a video to show you the demo, as seen below.
https://shotr.dev/8sE17.mp4

Thanks!

@GregorBiswanger
Copy link
Member

Thank you very much for the great work! With the next update 8.31.2 your feature will be included :) That enriches the community very much ... if you send me your address via Gitter, I can send you Electron.NET stickers if you want :)

We have the demo app again separately.. would be cool if you could test it there again... as soon as our update has been published, it will also be used there:
https://github.com/ElectronNET/electron.net-api-demos

@zacbre
Copy link
Contributor Author

zacbre commented May 12, 2020

We have the demo app again separately.. would be cool if you could test it there again... as soon as our update has been published, it will also be used there:
https://github.com/ElectronNET/electron.net-api-demos

I will submit a PR soon with changes to the demo that includes the support for showing off the copy + paste for clipboard and images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants