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:
1 |
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAKK0lEQVRYR5VXC1RU1Rree868YGaAGRmew2OYAR+lUKZGKhfDQExAKc0HlmZJidq1la2rWYbd66vrWxNKzdKr5K2rrsIeaplKkoMaCqEgCCrCMMAMM8yZxzlnzt37zBwayGu3vda/9us/+/v+b/9n73Mg8Cs/XDOk3zLeSmtsbxlfXVMdI5crVLJAqUitVBBqpVwYKGNFIikllEg9gGbtoLU5tmbVjKLh/BIfzZh+KW9aXkrVRUPP5C3bVP5r/6829J+I0EVPSM4b+9Gyl3J0QgkJhASaRR5OuhewqOFCtYO2c4/cM5GgwRB4pmT5hmLUPVOaP/XytOnPpojcbm7NM5UXbdN2lwT9EYl+BDCcOiQkZVhBevnyokmRUqkAAfYCJ4NBIXBQiABuswA0tZCgt0a9f9eq9ds/yM1F+DmPSQgCsg6yD/OM4Yo1f+/e4AeRGEiA840KDR2cMmP0kamzM0fIVQgUAXMEUPTYED5oqKNpab16U1JV9ayZeVM0BEEI8LMeu1chvpw0XLbOKvvMnwQsyZ1yNmfFW8XRqamn7ktg2DCdftTLky5PmBihMJJ3gc1tAW7GBXoREYZlAAFFoOo0RdaWXHorW6NJeHPa1IUJIcESDIoVwASx4cKQDvB9XYO14OhRjsTHWZntjw0bEn41SLlzTnHxmt8RSEqKTdDOfKIqKY1UmshW4PZQgEWr4RzgFubaAFR+wfSMaA8vunz5p3PjwmJXrsydMk8XLJdgQM6PoQFtMgHXPbQGqk9YHV0EBM50QEdbgQC0Ppn5bUFJyaJ+BDQ6jd6dqvxpdD6h9vhCwLW3CQHfxiQMZbRFfLatoLOz87RKpRKPVSs3Ls/MmqcloMR99w5wXL8OaJeLe9aDzASFgEF1KOo50VpHKc+1rbea5/YRiI+PiLeNC7uYkkuocbQPKphA1QFXp+2r2jnI7xTG0GiCVMkB6rVzZIEFQ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ps3wbkdbbRj59j7w+eELHWVovjE6bWU5NXOenhWjS3cgAfwp5Hahc9wBYI+Zlpz+6s6NU8VjFAoFVvk3BQay8u/3KYFISNQWYvWn8NihCuMB5HMTXeW3o9Lfu+PMmBQGSBIQ5m4Gmk0ugd3qETicLEujQ4BGEy6zhXUY22lLS83TWU9c+vTjDw9jan1b8CACvjnJU8mR88drxc+8c6xlExprQlYfHx8fQoVlf0O7zBD0trazjk4j7bIaacre4XaSXSgB0WmAfqpQjfyRFAD/OOJLrBsZd5c8+AegPzN8v0ciC0X2C6+gUqkMMpvNyajvRIa/ETEIBuRB8SHs/TW4T/kvz+Dpv0L5318AAAAASUVORK5CYII= |
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:
1 2 3 4 5 6 7 8 9 |
byte[] bytes = YOUR BINARY SOURCE; Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); //Make sure that the type Response.ContentType = "image/png"; Response.BinaryWrite(bytes); Response.Flush(); Response.End(); |