将byte[]转为WriteableBitmap对象

//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。

你可能感兴趣的:(Stream,byte)