question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for the display of various image/picture types (e.g., bitmaps)

See original GitHub issue

Is your feature request related to a problem? Please describe. I would like to have images displayed in a .NET Interactive Notebook when working in Visual Studio Code with the .NET Interactive Notebooks extension. In particular, support for displaying SkiaSharp elements, such as images, bitmaps, etc. would be great.

Describe the solution you’d like An example script might be:

#r "nuget: SkiaSharp"
open SkiaSharp
let bitmap = new SKBitmap(200, 200) // creates a default SKBitmap
// do some stuff to the bitmap, such as calling bitmap.SetPixel to manually set pixels
let image = SKImage.FromBitmap(bitmap) // creates an SKImage from a bitmap
let data = image.Encode() // encodes the image as a PNG

image

Then I’d like either of bitmap, image, or data left as the last element in the cell to have the underlying image displayed in the cell output, just as XPlot.Plotly does with its various charts and plots. The code above actually all works inside a notebook right now, and I’m able to save the image to a file. But I’d love the image to just directly appear in the cell’s output.

For example:

image

If this is possible right now, then I am not sure how to get it to happen and would love any pointers if it is possible.

Describe alternatives you’ve considered I considered trying to load various views that would load external to notebook, such as using SkiaSharp.Views.Forms, Xamarin.Forms, etc. However, that’s not much different than just running things in an F# script (.fsx file). Having the image immediately displayed would be fantastic for all sorts of use cases.

Edit: I edited it because I submitted by accident while creating it.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:24 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
bmitccommented, Jan 25, 2022

@rdthree SkiaSharp is a general API for drawing. For .NET Interactive notebooks, one can implement some custom formatters so that datatypes get specially displayed in the notebook (such as Plotly.NET). To get the interactive behavior, you sometimes need to reference another Nuget package (such as how Plotly.NET does it). I think @mattleibow’s plan was to include the SkiaSharp extension in the already existing Nuget package, so you wouldn’t need to separately reference an extension package. He added some basic support (see here and here), but I’m not sure if it got released in a Nuget release and/or if it’s still current. I believe he did it as a quick trial implementation where it wasn’t intended to be feature complete.

I didn’t know surface.Snapshot().Display() would work like that, so maybe that’s the extension at work (?) or some new features of .NET Interactive (?). Someone else would know. I just created this feature suggestion. 😃

1reaction
mattleibowcommented, Aug 18, 2021

In the latest previews of SkiaSharp I added some elements, but I also had to use base64.

Would be cool to be able to do this automatically. And if it supports images, it might be nice for workbooks to have some basic info like size and stuff.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CircuitPython Display Support Using displayio
It allows for some common tasks like displaying bitmap images, drawing text with fonts, etc. However, there are also some fancy additional ...
Read more >
Types of Bitmaps - Windows Forms .NET Framework
Learn about bitmap types and the supported GDI+ graphics file formats, including BMP, JPG, GIF, PNG, and TIFF.
Read more >
Cell hint for a cxGrid column of type "Image"
The column is of type "Image" and property "GraphicClassName" is set to "TdxSmartImage" to support different graphics. I fill there bmps, jpegs ...
Read more >
Delphi Images - mc-computing.com
All images in an image list are contained in a single, wide bitmap in screen device format. but, apparently, that is not true....
Read more >
How to get information about an image (picture) from the ...
Both commands will show info on all media files in the current folder and subfolders. Show info on all JPG images starting from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found