sql >> Base de Datos >  >> RDS >> Oracle

Cómo agregar un 'System.Drawing.Image' a un 'System.Web.UI.WebControls.Image'

Parece que solo desea un método simple para convertir una matriz de bytes de imagen en una imagen. No hay problema. Encontré un artículo eso me ayudó mucho.

    System.Web.UI.WebControls.Image image = (System.Web.UI.WebControls.Image)e.Item.FindControl("image");

    if (!String.IsNullOrEmpty(currentAd.PictureFileName))
    {
        image.ImageUrl = GetImage(currentAd.PictureFileContents);
    }
    else
    {
        image.Visible = false;
    }

    //The actual converting function
    public string GetImage(object img)
    {
        return "data:image/jpg;base64," + Convert.ToBase64String((byte[])img);
    }

PictureFileContents es un Byte[] y eso es lo que la función GetImage toma como objeto.