You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Quite OK Image (QOI) format encoder/decoder written in C++20.
Dependencies
C++20
Usage
You can use CMake FetchContent to add this repo to your project.
include(FetchContent)
FetchContent_Declare(
qoippGIT_REPOSITORYhttps://github.com/mrizaln/qoippGIT_TAGv0.5.0
) # or use commit hashFetchContent_MakeAvailable(qoipp)
add_executable(mainmain.cpp)
target_link_libraries(mainPRIVATEqoipp)
No exception; all operation that can fail returns a Result<T>. On C++23 this is an std::expected<T, Error>.
#include<qoipp.hpp>intmain()
{
{ // read directly from fileauto image = qoipp::decode_from_file("./path/to/file.qoi");
if (not image) {
std::cout << to_string(image.error()) << '\n'; // using ADLreturn1;
}
// image->data is the raw image bytes decoded from the file// image->desc is the image description (width/height/channels/colorspace)// do something with the image data...
}
{ // decode data already in memoryauto data = /* qoi image bytes read from file for example */;
auto image = qoipp::decode(data);
if (not image) {
std::cout << to_string(image.error()) << '\n'; // using ADLreturn1;
}
// do something with the image data...
}
{ // there's also an overload that can take a buffer as an out parameterauto data = /* qoi image bytes read from file for example */;
auto buffer = Vec(/* width * height * channels */);
auto desc = qoipp::decode_into(buffer, data);
if (not desc) {
std::cout << to_string(desc.error()) << '\n'; // using ADLreturn1;
}
// do something with the data in the buffer...
}
// those above are all decode* functions, the opposite encode* functions are also present
}
See example for more usage or read the header directly.
About
A Quite OK Image (QOI) format codec written in C++20