BitmapImage bmp = new BitmapImage(new Uri("Images\\DefaultPhoto.jpg",UriKind.Relative));
byte[] byteArray = null;
try
{
Stream sMarket = bmp.StreamSource;//bmp的StreamSource为null,可我不是已经赋值了吗?而且能显示图像了
if (sMarket != null && sMarket.Length > 0)
{
sMarket.Position = 0;
using (BinaryReader br = new BinaryReader(sMarket))
{
byteArray = br.ReadBytes((int)sMarket.Length);
}
}
}
catch
{
//other exception handling
}