How to display an image on the website from a binary source (e.g. a database)

There are various ways in which one could display an image on the website form a binary source. One solution would invole simply converting the binary source into a base64 and put it as the src of the image:

the result of applying image

However, this is not acceptable if you load images 'on demand' i.e. when the user reaches the point when the image is needed. In those cases you might want to try having some sort of service which will get the images only when they are needed. In C#, to convert binary source into an acceptable image format try this code: