逐行创建位图文件
是否可以用 C# 逐行编写位图?我担心在处理大文件时使用 Bitmap.Save() 函数会需要太多内存。
为了澄清,我想这样做:
- 打开文件并写入位图标头(如果有)
- 放入 1 个扫描线将图像数据写入缓冲区 (byte[])
- 将缓冲区的内容写入文件
- 除非不再有扫描线,否则从 2 开始重复
- 关闭文件
这在 C# 中是如何完成的?
谢谢,
克雷布
Is it possible to write a bitmap in C# line by line? I am worried that using the Bitmap.Save() function will require too much memory when dealing with LARGE files..
To clarify, I want to do this:
- Open the file and write the bitmap header (if any)
- Put 1 scanline worth of image data into a buffer (byte[])
- Write the contents of the buffer into the file
- Repeat from 2 unless there are no more scan lines
- Close the file
How is this done in C#?
Thanks,
kreb
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Mikael
它看起来像这样:
我担心对于非常大的图像,bigBuffer可能会变得太大..我想将其更改为逐行写入文件,而不是一次性写入..
谢谢..: )
@Mikael
It looks like this:
I am worried that for really big images, bigBuffer might become too big.. I would like to change this to write to file line by line, instead of writing it in one go..
Thanks.. :)
我曾经编写过一些保存 32kx32k 像素 JPEG 文件的代码。我在创建、加载、查看和操作它时遇到了很多问题(Photoshop 可以处理最大 30kx30k 的文件)。
在尝试分配之后,我放弃了整个交易,并决定将大图像的一部分保存为小图像,并编写一些管理器程序,该程序知道如何在需要时“缝合”这些文件。
我不确定您什么时候进入,但如果它是为了显示,那么您可以查看 DeepZoom
I was once writing some code that saved a 32kx32k pixels JPEG file. I had tons of problems with creating it, loading it, viewing it and manipulating it (Photoshop can handle files up to 30kx30k).
After trying allot I dropped the whole deal and decided on saving parts of the big image to small images and write some manager program that knows how to "stitch" these files when needed.
I'm not sure when you are in to but if it is for display then you might check out DeepZoom