We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looking for a Containers::Array from ImageData2D implementation as per gitter chat.
Use case: when ex. don't need to iterate over all pixels, but just need to fetch one or a certain portion continuously.
The text was updated successfully, but these errors were encountered:
For the record (also grabbed from Gitter), this is (an untested) snippet that should work for most common image formats:
#include <Corrade/Utility/Algorithms.h> // for copy() Containers::Array<Color4ub> outputData{std::size_t(image.size().product()), Containers::DirectInit, Color4ub{0, 0, 0, 255}}; // set alpha to 1 by default Containers::StridedArrayView2D<Color4ub> output{outputData, {std::size_t(image.size().y()), std::size_t(image->size().x())}}; if(image.format() == PixelFormat::RGBA8Unorm) { Utility::copy(image.pixels<Color4ub>(), output); } else if(image.format() == PixelFormat::RGB8Unorm) { Utility::copy(image.pixels<Color3ub>(), Containers::arrayCast<Color3ub>(output)); // alpha stays at 255 } else if(image.format() == PixelFormat::R8Unorm) { // broadcasts the red channel to RGB Utility::copy(Containers::arrayCast<const UnsignedByte>(image.pixels()).broadcast<2>(3), Containers::arrayCast<3, UnsignedByte>(output)); // alpha stays at 255 } else Fatal{} << "Oh noes!";
Sorry, something went wrong.
No branches or pull requests
Looking for a Containers::Array from ImageData2D implementation as per gitter chat.
Use case: when ex. don't need to iterate over all pixels, but just need to fetch one or a certain portion continuously.
The text was updated successfully, but these errors were encountered: