天天看點

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

繼續閱讀