From 4e1823a8690992e6e0d9c54e41b333ea0dbc2be7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Mar 2023 14:28:04 +0100 Subject: src/anim-atlas: put in adapted old bitmask code --- src/anim-atlas.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 434f34b6..45e23445 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -129,19 +129,18 @@ auto anim_atlas::frame_quad(const Vector3& center, rotation r, std::size_t i) co void anim_atlas::make_bitmask_(const ImageView2D& tex, BitArray& array) { + constexpr unsigned char amin = 32; const auto pixels = tex.pixels(); const auto size = pixels.size(); - const auto width = size[1], height = size[0], - stride = (std::size_t)pixels.stride()[0], width0 = width & ~7u; + const auto width = size[1], height = size[0]; + const auto stride = (std::size_t)pixels.stride()[0], width0 = width & ~7u; + fm_assert(tex.pixelSize() == 4 && pixels.stride()[1] == 4); const auto* const data = (const unsigned char*)pixels.data(); +#if 0 auto* const dest = (unsigned char*)array.data(); - fm_assert(tex.pixelSize() == 4); - fm_assert(pixels.stride()[1] == 4); - for (auto j = 0_uz; j < height; j++) { - constexpr unsigned char amin = 32; auto i = 0_uz; for (; i < width0; i += 8) { @@ -165,6 +164,11 @@ void anim_atlas::make_bitmask_(const ImageView2D& tex, BitArray& array) array.set((height-j-1)*width + i, alpha >= amin); } } +#else + for (std::size_t y = 0; y < height; y++) + for (std::size_t x = 0; x < width; x++) + array.set(y*width + x, data[(height-y-1)*stride + x*4 + 3] >= amin); +#endif } BitArray anim_atlas::make_bitmask(const ImageView2D& tex) -- cgit v1.2.3