load bitmap from vector

This commit is contained in:
Robin Rottstädt 2023-09-23 22:12:21 +02:00
parent f0316c3205
commit 237102965b
No known key found for this signature in database
GPG key ID: 630B61F1D46CCE35

View file

@ -54,6 +54,17 @@ struct Bitmap final {
return {.size = size, .data = {values...}};
}
/**
* @brief creates a bitmap from RGBA Values
* @param[in] size extent of bitmap
* @param[in] data vector of RGBA values
* @return bitmap with data from this call
*/
static constexpr Bitmap from_data(Size size, std::vector<RGBA> data) noexcept {
assert(data.size() == size.height * size.width);
return {.size = size, .data = data};
}
/**
* @brief fills a bitmap uniformly
* @param[in] color RGBA value of a color
@ -87,10 +98,7 @@ struct Bitmap final {
return data[y * size.width + x];
}
constexpr void force_change() noexcept
{
change_count++;
}
constexpr void force_change() noexcept { change_count++; }
Size size{.width = 0, .height = 0}; //!< extent of bitmap
std::vector<RGBA> data{}; //!< data storage