(1)图片从文件导入
BitmapImage image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(filename);
image.EndInit();
(2)图片从Binary导入
//已知Binary binary
MemoryStream ms = new MemoryStream(binary.ToArray());
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = ms;
image.EndInit();
(3)保存图片文件
//已知BitmapImage image
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
FileStream fileStream = new FileStream(imageFileName, FileMode.Create, FileAccess.ReadWrite);
encoder.Save(fileStream);
fileStream.Close();
(4)图片应用到材质
//已知BitmapImage image
ImageBrush imageBrush = new ImageBrush(image);
DiffuseMaterial material = new DiffuseMaterial();
material.Brush = imageBrush;
本文来自David博客,转载请标明出处:http://blog.csdn.net/wmjcom/archive/2010/12/10/6068130.aspx