In the past, when I wanted to display a dynamically generated image in ASP.NET, I would have a standalone aspx page that would stream back the image bytes using a image ContentType.
I recently found out that you can also stream images by setting the src attribute of the image with encoded bytes. This can be easily done using the ASP.NET Image control. Assume you have "myobject" that contains an image byte[] property called "imagebytes":
image1.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(myobject.imagebytes);
This will increase the size of your HTML since the image bytes are encoded directly into the HTML source. But hey, you don't need a separate aspx file.
Yippie.
Just some random development ramblings mostly related to the Microsoft .NET platform.
Subscribe to:
Post Comments (Atom)
Can't RDP? How to enable / disable virtual machine firewall for Azure VM
Oh no! I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore. I did ...
-
Don't want Office 2007 installed on your web server to access Excel 2007 content? Here is a Visual Studio C# solution that demonstrates ...
-
I finally found a good algorithm to validate a file path (had to fix two bugs in it though). I use this static method in Windows Forms when...
No comments:
Post a Comment