更新时间:2022-02-14 02:42:11
wxWidgets不提供任何API来自 wxBitmap
(因为它是平台相关的),但是 wxImage
使用一个定义明确(非常简单)的格式,你可以使用 GetData )
方法。只要注意,如果你的图片有alpha通道,你可能还需要使用 GetAlpha()
。
wxWidgets doesn't provide any API to the data from wxBitmap
(because it's platform-dependent) but wxImage
uses a well-defined (and very simple) format which you can access using its GetData()
method as mentioned above. Just notice that you may need to use GetAlpha()
as well if your images have alpha channel.
是不是我会这样做,因为如果你这样做,数据将巨大。虽然压缩它,如上所述,也是可能的,为什么要在 wxImage
已经支持以任何标准图像格式编写图像时手动进行。只需创建一个 wxMemoryOutputStream
并将其传递给 SaveFile()
。然后直接使用 GetOutputStreamBuffer() - > GetBufferStart()
和相关函数访问流缓冲区。
However this is not how I'd do it because the data will be huge if you do it like this. While compressing it, as also suggested above, is possible, why bother doing it manually when wxImage
already supports writing image in any of the standard image formats. Just create a wxMemoryOutputStream
and pass it to SaveFile()
. Then simply access the stream buffer directly using GetOutputStreamBuffer()->GetBufferStart()
and related functions.