我想将 PNG 图像从文件加载到缓冲区,然后加载到HPDF_Image
,但我无法使用 缓冲区从缓冲区获取图像HPDF_LoadPngImageFromMem
,因为它返回HPDF_INVALID_PNG_IMAGE
。
// Getting size
std::ifstream t("3CM//A_3cm2.png");
t.seekg(0, std::ios::end);
size_t size = t.tellg();
// Filling buffer
std::string buffer(size, ' ');
t.seekg(0);
t.read(&buffer[0], size);
// Loading Image from buffer
HPDF_Image image = HPDF_LoadPngImageFromMem(pdf, (HPDF_BYTE*) buffer.c_str(), buffer.size());