Im having trouble encoding and decoding from webp using libwebp in c++. I built this test application which takes webp file i created (which looks fine in chrome), and tried decoding it to rgb, and back to webp, just to understand how to use it, and the output is wrong:
//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 ////
As you can see, all i tried to do is manage to encode and decode the webp, and trying to save it back to a file, but as i try to open the file, it looks corrupted.
Can you please help me figure out what the problem is? more over, i would be happy to know some more about the stride param, and about the rgb format, and how to convert pictures to it to check if my code works.
Thanks alot!