summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anim-atlas.cpp14
-rw-r--r--src/anim-atlas.hpp1
2 files changed, 11 insertions, 4 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index ffade2d6..c6193b5b 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -127,15 +127,14 @@ auto anim_atlas::frame_quad(const Vector3& center, rotation r, std::size_t i) co
}};
}
-BitArray anim_atlas::make_bitmask(const ImageView2D& tex)
+void anim_atlas::make_bitmask_(const ImageView2D& tex, BitArray& array)
{
const auto pixels = tex.pixels();
const auto size = pixels.size();
- const auto width = size[1], height = size[0], dest_len = width*height,
+ const auto width = size[1], height = size[0],
stride = (std::size_t)pixels.stride()[0], width0 = width & ~7u;
const auto* const data = (const unsigned char*)pixels.data();
- auto* const dest = new unsigned char[(dest_len+7)>>3];
- auto array = BitArray{dest, 0, dest_len, {}};
+ auto* const dest = (unsigned char*)array.data();
fm_assert(tex.pixelSize() == 4);
fm_assert(pixels.stride()[1] == 4);
@@ -165,6 +164,13 @@ BitArray anim_atlas::make_bitmask(const ImageView2D& tex)
array.set((height-j-1)*width + i, alpha >= amin);
}
}
+}
+
+BitArray anim_atlas::make_bitmask(const ImageView2D& tex)
+{
+ const auto size = tex.pixels().size();
+ auto array = BitArray{NoInit, size[0]*size[1]};
+ make_bitmask_(tex, array);
return array;
}
diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp
index eaddef21..e5446c82 100644
--- a/src/anim-atlas.hpp
+++ b/src/anim-atlas.hpp
@@ -48,6 +48,7 @@ struct anim_atlas final
fm_DECLARE_DELETED_COPY_ASSIGNMENT(anim_atlas);
+ static void make_bitmask_(const ImageView2D& tex, BitArray& array);
static BitArray make_bitmask(const ImageView2D& tex);
private: