c# - 在 C# 中从内存流(视频)创建缩略图的最佳方法或库是什么?

标签 c# video dll movie video-thumbnails

我必须在 c# 中创建多个缩略图并保存在 amazon s3 上。我找不到只能从源文件的内存流创建缩略图的库。但是不能有文件源,我只有上传的流,我不想将文件保存在本地。

谢谢你的帮助!

最佳答案

简单的 C# 代码可以为您完成这项工作。您可以从字节数组创建缩略图。 首先通过以下代码将您的内存流对象转换为字节数组

byte[] bytes = memoryStream.ToArray();

然后你可以使用下面的方法

public byte[] MakeThumbnail(byte[] myImage, int thumbWidth, int thumbHeight)
{
    using (MemoryStream ms = new MemoryStream())
    using (Image thumbnail = Image.FromStream(new MemoryStream(myImage)).GetThumbnailImage(thumbWidth, thumbHeight, null, new IntPtr()))
    {
        thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        return ms.ToArray();
    }
}

关于c# - 在 C# 中从内存流(视频)创建缩略图的最佳方法或库是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35792141/

相关文章:

opencv - 使用 opencv 从眼睛玩具网络摄像头流式传输视频时出现 HIGHGUI 错误

html - 如何在 native 播放器中播放 HTML 5 视频?

c++ - DLL 中的全局构造函数和 MSVCRT

python - 在 python 中使用 libVLC 从内存中播放视频

c# ->net Reflector 中的 $ArrayType$16008 是什么?

将 C 声明转换为 Delphi XE2

c# - 获取静态类的静态方法的MethodInfo

c# - 检查现有的 'wired up' 方法

c# - 向 SpeechSynthesizer 添加新语言

c# - 0 到枚举的隐式转换