gpt4 book ai didi

c# - 将 MagickImage 转换为位图

转载 作者:行者123 更新时间:2023-12-05 09:32:47 26 4
gpt4 key购买 nike

我以为这会更容易,但我找不到办法。如何将 MagickImage 转换为 System.Drawing.Image(例如位图)

    public System.Drawing.Image CreateThumbnailIcon(string sourceImagePath, int iconSize )
{
MagickImage image = new MagickImage(sourceImagePath);
MagickGeometry geometry = new MagickGeometry(iconSize, iconSize);
image.Resize(geometry);
return image.??????;
}

最佳答案

我无法确认这是否有效,我是凭内存这样做的,但请试一试:

MagickImage image = new MagickImage(sourceImagePath);
MagickGeometry geometry = new MagickGeometry(iconSize, iconSize);
image.Resize(geometry);

using (var memStream = new MemoryStream())
{
// Write the image to the memorystream
image.Write(memStream);

return new System.Drawing.Bitmap(memStream);
}

关于c# - 将 MagickImage 转换为位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67638069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com