You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C#中加载特定JPG为Bitmap时出现“参数无效”异常

从流初始化Bitmap时抛出“参数无效”异常

我尝试将图片读取到流中并初始化Bitmap对象,但抛出了“参数无效”的异常,具体代码如下:

using (var webClient = new Classes.WebClient())
    using (var stream = webClient.OpenRead(filePath))
        using (var tempBitmap = new Bitmap(stream))
        {
            if (tempBitmap.Width > 500)
                logoBitmap = CustomImageProcessor.ResizeToWidth(tempBitmap);
            else
                logoBitmap = new Bitmap(tempBitmap);
        }

涉及的图片文件名为:RDT_20230224_0134133530323197128594639.jpg

异常信息及堆栈跟踪:

Message: 参数无效。
Stack Trace: at System.Drawing.Bitmap..ctor(Stream stream) at LaunchPad3_1.Visual.Visual2.<>c__DisplayClass20_0.b__0(ViewPoint viewPoint) in C:\Users\Rob\source\repos\LaunchPad3_1\LaunchPad3_1\Visual\Visual2.cs:line 311

内容的提问来源于stack exchange,提问作者Rob_Da_Joyce

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 03:52:05