如何使用ImageURL显示图像 [英] How to show image using ImageURL
问题描述
下午好。
我正在尝试使用ImageURL显示图像,系统正在返回"IndexOutOfRangeException",但是当我正在调试时,一切正常。
I'm trying to show an image using ImageURL and the system is returning "IndexOutOfRangeException", but when I'm debugging everything works well.
请帮助我吗?
Can you help me, please?
代码是:
byte [ ] LBYT_Aux;
              if(PINT_CdItemVerif == 0 || PINT_Tipo == 1)
              {
                  if(PINT_CdItemVerif == 0)
                      LBYT_Aux = ClsCheckList.FU_CarregaFotoMestreCheck(PINT_NrCheckList);
                 否则
                  {
                      System.Data.DataTable LDTT_Dados = ClsCheckList.FU_SelecionaFotoIdentificacao(PINT_NrCheckList.ToString(),PINT_CdItemVerif.ToString(),PINT_CdEmpresa.ToString(),PINT_CdFilial.ToString());
                      LBYT_Aux =(byte [])LDTT_Dados.Rows [0] [" Foto"];
$
                  }¥b $ b                   if(LBYT_Aux!= null)
                      IMG_Foto.ImageUrl =" data:image / png; base64," + Convert.ToBase64String(LBYT_Aux);
byte[] LBYT_Aux;
if (PINT_CdItemVerif == 0 || PINT_Tipo == 1)
{
if (PINT_CdItemVerif == 0)
LBYT_Aux = ClsCheckList.FU_CarregaFotoMestreCheck(PINT_NrCheckList);
else
{
System.Data.DataTable LDTT_Dados = ClsCheckList.FU_SelecionaFotoIdentificacao(PINT_NrCheckList.ToString(), PINT_CdItemVerif.ToString(), PINT_CdEmpresa.ToString(), PINT_CdFilial.ToString());
LBYT_Aux = (byte[])LDTT_Dados.Rows[0]["Foto"];
}
if (LBYT_Aux != null)
IMG_Foto.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(LBYT_Aux);
                      //这是问题
                  }
}
谢谢。
推荐答案
嗨格伦,
>> IMG_Foto.ImageUrl =" data:image / png; base64," + Convert.ToBase64String(LBYT_Aux);
无法判断哪个代码导致异常,我想知道它是否与 LBYT_Aux 相关,但是你可以跳过 LBYT_Aux
并使用图片的本地路径代替,然后检查它。
Can't tell which code caused the exception, I wonder if it's related to LBYT_Aux, but you may skip the LBYT_Aux and use the local path of image instead, to check it.
var bytes = File.ReadAllBytes("C:\\somepath\\picture.png");
var b64String = Convert.ToBase64String(bytes);
var dataUrl = "data:image/png;base64," + b64String;
祝你好运,
弗莱彻
这篇关于如何使用ImageURL显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!