大位图序列化
有没有一种简单的方法或免费的库可以让您将小位图附加到文件上的一个大位图中?我正在捕获有时垂直方向相当大的网页。为了避免 OOM 异常,我将捕获的小垂直片段和完整水平片段加载到内存中,并希望将它们保存到磁盘。附加到打开的文件流会很棒。我不是位图格式方面的专家,但我知道可能有页眉/页脚信息可能会阻止这种情况。
Is there an easy way, or free library, that will allow you to append small bitmaps into one large bitmap on file? I'm doing a capture of a web page that sometimes is quite large vertically. To avoid OOM exceptions I load small vertical by full horizontal slices of the capture into memory and would like to save those to disk. An append to an open filestream would be great. I'm not an expert on the Bitmap format but I am aware there is probably header / footer information that may prevent this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有标题信息,但它的大小是固定的。您可以编写标题信息,然后附加像素行,记录高度和其他信息。完成后,定位到文件的前面并更新标题。
位图文件格式是对该格式的很好的描述。
我建议使用版本 3 格式,除非您确实需要 V4 结构中的某些内容。每像素 24 位是最容易处理的,因为您不必弄乱调色板。 16 和 32 位颜色比 4 和 8 位颜色(需要调色板)更容易。
There is header information, but it's a fixed size. You could write the header information and then append rows of pixels, keeping track of the height and other information. When you're done, position to the front of the file and update the header.
Bitmap File Format is a pretty good description of the format.
I would suggest using the version 3 format unless there's something you really need from the V4 structure. 24 bits per pixel is the easiest to deal with, since you don't have to mess with a color palette. 16 and 32 bit color are easier than 4 and 8 bit color (which require a palette).