我在 c++ 中使用 libwebp 从 webp 编码和解码时遇到问题。我构建了这个测试应用程序,它采用我创建的 webp 文件(在 chrome 中看起来很好),并尝试将其解码为 rgb,然后返回 webp,只是为了了解如何使用它,但输出错误:
//Code before reads the webp file, and assigning it to a uint8_t buffer called "pic" ///
WebPConfig config;
ASSERT(WebConfigIit(&config) == TRUE)
int width=0 height =0;
uint8_t * rgb = WebPDecodeRGB(pic, size, &width, &height)
ASSERT (rgb != NULL)
// At this point the width and the height is valid, and the rgb is assigned.
uint8_t* originalPic = null;
size_t size = WebPEncodeRGB(rgb, width, height, height, &originalPic);
// Didn't quite know what to put in the stride param..
/// Code after saves the originalPic buffer to a file ////
如您所见,我所做的只是设法对 webp 进行编码和解码,并尝试将其保存回文件,但是当我尝试打开文件时,它看起来已损坏。
你能帮我弄清楚问题是什么吗?此外,我很乐意了解更多关于步幅参数、rgb 格式以及如何将图片转换为它以检查我的代码是否有效的信息。
非常感谢!