C#“参数无效."创建新位图 [英] C# "Parameter is not valid." creating new bitmap

查看:38
本文介绍了C#“参数无效."创建新位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试创建大于 19000 像素的位图,则会收到错误消息:参数无效.我该如何解决这个问题??

if I try to create a bitmap bigger than 19000 px I get the error: Parameter is not valid. How can I workaround this??

System.Drawing.Bitmap myimage= new System.Drawing.Bitmap(20000, 20000);

推荐答案

请记住,您正试图使用​​该位图分配大量内存.

Keep in mind, that is a LOT of memory you are trying to allocate with that Bitmap.

参考http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/37684999-62c7-4c41-8167-745a2b486583/

.NET 可能拒绝创建一个一次性用完这么多连续内存的映像.

.NET is likely refusing to create an image that uses up that much contiguous memory all at once.

有点难读,但这个参考也有帮助:

Slightly harder to read, but this reference helps as well:

http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.drawing/2005-06/msg00176.html

系统中的每个图像都有由这个公式定义的内存量:

Each image in the system has the amount of memory defined by this formula:

位深*宽*高/8

这意味着 40800 x 4050 像素的图像将需要超过 660兆字节的内存.

This means that an image 40800 pixels by 4050 will require over 660 megabytes of memory.

这篇关于C#“参数无效."创建新位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆