zoukankan      html  css  js  c++  java
  • 关于SilverLight3D Balder中动态材质的问题(转)

          创建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);
    }
    }
  • 相关阅读:
    poj 2560Freckles (krusual)
    ACRush 楼天成回忆录
    大腕版ACMICPC比赛
    POJ刷题
    DataGrid中添加DropdownList时的数据绑定
    【转帖】SQL Server各种日期计算方法(收藏)
    安全配置Win2000服务器
    C#写的一个代码生成器
    .Net 常用加密算法类
    实习之最
  • 原文地址:https://www.cnblogs.com/yanghaihao/p/2777473.html
Copyright © 2011-2022 走看看