Ver código fonte

added BytesPerPixel() method to PixelFormat structure

legacy
Benlitz benlitz 11 anos atrás
pai
commit
60b06ee98e
2 arquivos alterados com 17 adições e 14 exclusões
  1. +16
    -0
      src/lol/gpu/texture.h
  2. +1
    -14
      src/tileset.cpp

+ 16
- 0
src/lol/gpu/texture.h Ver arquivo

@@ -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


+ 1
- 14
src/tileset.cpp Ver arquivo

@@ -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;


Carregando…
Cancelar
Salvar