O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Returning an image response

To return a dynamic image we need to be able to draw it. SkiaSharp is a powerful cross-platform two-dimensional drawing engine. It will allow us to draw graphs and create images. Add the SkiaSharp NuGet package to the project. The SensorHttp project, in the GitHub repository for this book, contains a GenerateGauge()method that draws a gauge using SkiaSharp, based on the current momentary values. The method returns an object of type SKImage. Returning the image to the requester can be done very simply, as follows:

private void ReturnMomentaryAsPng(HttpRequest Request, 
   HttpResponse Response) 
{ 
   Response.Return(this.GenerateGauge(Request.Header)); 
} 

What happens when you return an object is that the web server checks ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required