//convert the bytes to WriteableBitmap
privateWriteableBitmap BytesToImage(byte[] src, int lw, int lh)
{
WriteableBitmap wbbitmap = newWriteableBitmap(lw, lh);
Stream s = wbbitmap.PixelBuffer.AsStream();
s.Seek(0, SeekOrigin.Begin);
s.Write(src, 0, lw * lh * 3);
return wbbitmap;
}
注:这里默认的WriteableBitmap对象为24位位图对象,如果是32位,则由流写入byte[]的时候要写为lw*lh*4。
Byte数组转WriteableBitmap
本文介绍了一种将byte数组转换为WriteableBitmap的方法。该方法适用于24位位图对象,若需处理32位位图,则需相应调整写入的像素数据大小。
189

被折叠的 条评论
为什么被折叠?



