【发布时间】:2012-02-28 16:27:24
【问题描述】:
我尝试在 google 中找到如何将 imageSource 转换为 byte[] - 我找不到这样做的原因。
有人可以帮忙吗?
谢谢。
【问题讨论】:
标签: silverlight
我尝试在 google 中找到如何将 imageSource 转换为 byte[] - 我找不到这样做的原因。
有人可以帮忙吗?
谢谢。
【问题讨论】:
标签: silverlight
如果你有 BitmapSource,你可以使用BitmapSource.CopyPixels Method (Array, Int32, Int32)
或者,如果您需要 ARGB 字节序列:
var bmp = new WriteableBitmap((BitmapSource)source);
byte[] pixels = bmp.Pixels.SelectMany(p => new byte[]
{
(byte)p,
(byte)(p >> 8),
(byte)(p >> 16),
(byte)(p >> 24)
}).ToArray();
【讨论】: