diff --git a/src/lol/gpu/texture.h b/src/lol/gpu/texture.h index 6173ca6b..83e8106b 100644 --- a/src/lol/gpu/texture.h +++ b/src/lol/gpu/texture.h @@ -36,6 +36,22 @@ struct PixelFormat inline PixelFormat() : m_value(Unknown) {} inline PixelFormat(Value v) : m_value(v) {} inline operator Value() { return m_value; } + + inline uint8_t BytesPerPixel() + { + switch (m_value) + { + case Y_8: + return 1; + case RGB_8: + return 3; + case RGBA_8: + case ARGB_8: + case ABGR_8: + default: + return 4; + } + } }; class Texture diff --git a/src/tileset.cpp b/src/tileset.cpp index 3423ed04..f7535f65 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -139,21 +139,8 @@ void TileSet::TickDraw(float seconds) } else if (m_data->m_image) { - int planes; PixelFormat format = m_data->m_image->GetFormat(); - - switch (format) - { - case PixelFormat::RGB_8: - planes = 3; - break; - case PixelFormat::RGBA_8: - case PixelFormat::ARGB_8: - case PixelFormat::ABGR_8: - default: - planes = 4; - break; - } + int planes = format.BytesPerPixel(); int w = m_data->m_texture_size.x; int h = m_data->m_texture_size.y;