| 686 | } |
| 687 | |
| 688 | bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size) |
| 689 | { |
| 690 | int width, height; |
| 691 | if (!WebPGetInfo(static_cast<const u8*>(buffer), buffer_size, &width, &height) || width <= 0 || height <= 0) |
| 692 | { |
| 693 | Console.Error("WebPGetInfo() failed"); |
| 694 | return false; |
| 695 | } |
| 696 | |
| 697 | std::vector<u32> pixels; |
| 698 | pixels.resize(static_cast<u32>(width) * static_cast<u32>(height)); |
| 699 | if (!WebPDecodeRGBAInto(static_cast<const u8*>(buffer), buffer_size, reinterpret_cast<u8*>(pixels.data()), |
| 700 | sizeof(u32) * pixels.size(), sizeof(u32) * static_cast<u32>(width))) |
| 701 | { |
| 702 | Console.Error("WebPDecodeRGBAInto() failed"); |
| 703 | return false; |
| 704 | } |
| 705 | |
| 706 | image->SetPixels(static_cast<u32>(width), static_cast<u32>(height), std::move(pixels)); |
| 707 | return true; |
| 708 | } |
| 709 | |
| 710 | bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality) |
| 711 | { |