圖片下載完了,就:
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 = new byte[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);
}
}
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()