Skip to content

Commit

Permalink
added: function to convert rgba <-> bgra.
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Jul 9, 2011
1 parent 3851c02 commit 972791b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions xbmc/guilib/Texture.cpp
Expand Up @@ -412,6 +412,19 @@ unsigned int CBaseTexture::PadPow2(unsigned int x)
return ++x;
}

bool CBaseTexture::SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements, unsigned int offset)
{
if (!pixels) return false;

This comment has been minimized.

Copy link
@davilla

davilla Jul 10, 2011

space monster been eating here ?

unsigned char *dst = pixels;
for (unsigned int y = 0; y < height; y++)
{
dst = pixels + (y * pitch);
for (unsigned int x = 0; x < pitch; x+=elements)
std::swap(dst[x+offset], dst[x+2+offset]);
}
return true;

This comment has been minimized.

Copy link
@davilla

davilla Jul 10, 2011

yummm

}

unsigned int CBaseTexture::GetPitch(unsigned int width) const
{
switch (m_format)
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/Texture.h
Expand Up @@ -89,6 +89,7 @@ class CBaseTexture
void ClampToEdge();

static unsigned int PadPow2(unsigned int x);
bool SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements = 4, unsigned int offset=0);

protected:
// helpers for computation of texture parameters for compressed textures
Expand Down

0 comments on commit 972791b

Please sign in to comment.