#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PIXELS_STORAGE_WEBP_LIBWEBPHELPERS_H #define NUCLEX_PIXELS_STORAGE_WEBP_LIBWEBPHELPERS_H #include "Nuclex/Pixels/Config.h" #if defined(NUCLEX_PIXELS_HAVE_LIBWEBP) #include "Nuclex/Pixels/PixelFormat.h" #include "Nuclex/Pixels/Storage/VirtualFile.h" #include // for std::uint8_t #include // for std::string #include // for ::VP8StatusCode namespace Nuclex { namespace Pixels { namespace Storage { namespace WebP { // ------------------------------------------------------------------------------------------- // /// Size of the smallest valid WebP file possible /// /// From https://github.com/mathiasbynens/small/blob/master/webp.webp /// constexpr const std::size_t SmallestPossibleWebPSize = 26; // bytes // ------------------------------------------------------------------------------------------- // /// Helper class for reading WebP files using libwebp class Helpers { /// /// Checks whether the first 16 bytes in a file are a valid WebP file header /// /// File header that will be checked /// True if the file header is a valid WebP file header /// /// The file header must contain at least the first 13 bytes of the file, /// otherwise this will segfault. /// public: static bool IsValidWebPHeader(const std::uint8_t *fileHeader); /// Returns an error message according to a VP8 status code /// Status code for which an error message will be provided /// The error message for the specified status code public: static std::string GetErrorMessage(::VP8StatusCode statusCode); }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Pixels::Storage::WebP #endif // defined(NUCLEX_PIXELS_HAVE_LIBWEBP) #endif // NUCLEX_PIXELS_STORAGE_WEBP_LIBWEBPHELPERS_H