创建Material时,用的本地的图片,怎么用网上的图片呢?
图片下载完了,就:
void down_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error ==null)
{
System.IO.Stream responseStream = e.Result;
BitmapImage bitmapImage =new BitmapImage();
bitmapImage.SetSource(responseStream);
WriteableBitmap bitmap =new WriteableBitmap(bitmapImage);
//注意是4哦,我一开始用的3,就显示不正常了
byte[] array =newbyte[bitmapImage.PixelHeight * bitmapImage.PixelWidth *4];
for (int i =0; i < bitmap.PixelHeight; i++)
{
for (int j =0; j < bitmap.PixelWidth; j++)
{
int index = bitmap.PixelWidth * i + j;
int pixel = bitmap.Pixels[index];
byte[] bytes = BitConverter.GetBytes(pixel);
//蓝波段(试验过)
array[index *4] = bytes[0];
//绿波段(试验过)
array[index *4+1] = bytes[1];
//红波段(试验过)
array[index *4+2] = bytes[2];
//透明度(应该是的吧)
array[index *4+3] = bytes[3];
}
}
Balder.Imaging.Image image =new Balder.Imaging.Image();
image.Width = bitmap.PixelWidth;
image.Height = bitmap.PixelWidth;
Balder.Imaging.IImageContext imageContext = image.ImageContext;
imageContext.SetFrame(array);
to3Dview(image);
}
else
{
MessageBox.Show(e.Error.Message);
}
}