Browse Source

added BytesPerPixel() method to PixelFormat structure

legacy
Benlitz benlitz 11 years ago
parent
commit
60b06ee98e
2 changed files with 17 additions and 14 deletions
  1. +16
    -0
      src/lol/gpu/texture.h
  2. +1
    -14
      src/tileset.cpp

+ 16
- 0
src/lol/gpu/texture.h View File

@@ -36,6 +36,22 @@ struct PixelFormat
inline PixelFormat() : m_value(Unknown) {} inline PixelFormat() : m_value(Unknown) {}
inline PixelFormat(Value v) : m_value(v) {} inline PixelFormat(Value v) : m_value(v) {}
inline operator Value() { return m_value; } 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 class Texture


+ 1
- 14
src/tileset.cpp View File

@@ -139,21 +139,8 @@ void TileSet::TickDraw(float seconds)
} }
else if (m_data->m_image) else if (m_data->m_image)
{ {
int planes;
PixelFormat format = m_data->m_image->GetFormat(); 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 w = m_data->m_texture_size.x;
int h = m_data->m_texture_size.y; int h = m_data->m_texture_size.y;


Loading…
Cancel
Save