【问题标题】:How to Convert ImageSource to byte[]?如何将 ImageSource 转换为 byte[]?
【发布时间】:2012-02-28 16:27:24
【问题描述】:

我尝试在 google 中找到如何将 imageSource 转换为 byte[] - 我找不到这样做的原因。

有人可以帮忙吗?

谢谢。

【问题讨论】:

标签: silverlight


【解决方案1】:

如果你有 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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多