WPF image控件无法显示图片
publicstaticBitmapImageGetBitmapimage(stringpath){using(BinaryReaderloader=newBinaryR...
public static BitmapImage GetBitmapimage(string path)
{
using (BinaryReader loader = new BinaryReader(File.Open(path, FileMode.Open)))
{
FileInfo fd = new FileInfo(path);
int length = (int)fd.Length;
byte[] buf = new byte[length];
buf = loader.ReadBytes((int)fd.Length);
loader.Close();
loader.Dispose();
BitmapImage bim = new BitmapImage();
bim.BeginInit();
bim.StreamSource = new MemoryStream(buf);
return bim;
}
}
image.source=GetBitmapimage(picpath);
图片出不来,图片是有的 展开
{
using (BinaryReader loader = new BinaryReader(File.Open(path, FileMode.Open)))
{
FileInfo fd = new FileInfo(path);
int length = (int)fd.Length;
byte[] buf = new byte[length];
buf = loader.ReadBytes((int)fd.Length);
loader.Close();
loader.Dispose();
BitmapImage bim = new BitmapImage();
bim.BeginInit();
bim.StreamSource = new MemoryStream(buf);
return bim;
}
}
image.source=GetBitmapimage(picpath);
图片出不来,图片是有的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询