Monday, 30 January 2017

C# ASP.NET Hide Image Path on the Page

public void DrawImage(string imageURL)
{
    // convert image to bytes array
    WebClient wClient = new WebClient();
    byte[] imageBytes = wClient.DownloadData(@imageURL);

         // create memory stream of bytes array and convert image to base 64 and display it

    MemoryStream imgStream = new MemoryStream(imageBytes);
    ImageBox.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String(imgStream.ToArray(), 0, imgStream.ToArray().Length);
}

*ImageBox is a image control on the page.
*Sample call: DrawImage("c:\windows\image.jpg")



No comments:

SQL: Generate a range of numbers

SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM       (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),      (VALU...