24bpp 位图就地转换为 32bpp
在 Delphi 7 中,我必须处理相当大的 24bpp 位图(几个 100 MB)。由于我想使用 Graphcis32 库进行进一步处理,因此必须将它们转换为 32bpp (TBitmap32)。然而,TBitmap32 的 LoadFromFile 方法会创建一个临时的常规 TBitmap 来加载原始 24bpp 位图,然后将其分配给 TBitmap32 以执行所需的格式转换。当然,内存中存在两个巨大的位图,内存负载大约会增加一倍,这对我的应用程序来说可能是致命的。
我正在考虑的是一种将 24bpp 位图加载到预先分配的缓冲区中的方法,该缓冲区的尺寸适合 32 bpp 位图。然后,从缓冲区末端开始,我想将 RGB 字节移动到 32bpp 所需的偏移量。
这可能吗?如何将位图加载到预分配的缓冲区中?有什么想法吗?
In Delphi 7, I have to deal with pretty large 24bpp bitmaps (several 100 MB). Since I want to use the Graphcis32 library for further processing, they have to be converted to 32bpp (TBitmap32). The LoadFromFile method of TBitmap32, however, creates a temporary conventional TBitmap to load the original 24bpp bitmap which is then assigned to the TBitmap32 to do the required format conversion. Of course, memory load is roughly doubled by having two of these huge bitmaps in memory, and this can be fatal to my application.
What I am thinking of is a way to load the 24bpp bitmap into a preallocated buffer which is dimensioned such that the 32 bpp bitmap fits in. Then, starting from the buffer end, I want to move the RGB bytes to the offsets needed for 32bpp.
Is this possible? How can I load a bitmap into a preallocated buffer? Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太了解 Graphics32 的工作原理。但是,如果您使用标准文件格式并可以直接访问 TBitmap32 像素数据,您应该能够为该格式创建自己的图像加载器,如果其他方法都不起作用,则可以一次性加载并向上转换为 32bpp。
常见文件格式的规范在互联网上随处可见,您使用哪一种?
I don't know much of how Graphics32 works. However if you use a standard file format and have direct access to the TBitmap32 pixel data you should be able create your own image loader for the format that does the loading and the up conversion to 32bpp in one go if nothing else works.
Specifications for common file formats are all over the internet, which one are you using?