This is what I currenty do to load images in my application:
auto b = ::FreeImage_Load(type, path.c_str());
void *bits;
auto hbmp = CreateDIBSection(
dc,
FreeImage_GetInfo(bitmap),
DIB_RGB_COLORS,
&bits,
0,
0
);
std::memcpy(bits, FreeImage_GetBits(b), size);
It works very well, but I'd like to avoid allocating memory twice - ::FreeImage_Load
already stores data in a way that's suitable for dib. Is there a way of calling CreateDIBSection
that would prevent allocation and would force dib created that way to use buffer provided by me? If not, is there another method that would allow that?
It seems that providing NULL
instead of **ppvBits
prevents allocation - is there a way to modify buffer address later? I've also tried tinkering with hSection
parameter but dibs created that way were incorrect.