Skip to content
Browse files

[rbp/texture] added support for images where texture size different f…

…rom decoded image size
  • Loading branch information...
1 parent d697108 commit a68f8fc094c0c89042106d2af02539bb6112179c Cory Fields committed Oct 9, 2012
Showing with 26 additions and 4 deletions.
  1. +26 −4 xbmc/guilib/Texture.cpp
View
30 xbmc/guilib/Texture.cpp
@@ -70,11 +70,13 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
while (GetPitch() < g_Windowing.GetMinDXTPitch())
m_textureWidth += GetBlockSize();
+#if !defined(TARGET_RASPBERRY_PI)
if (!g_Windowing.SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0))
{
m_textureWidth = PadPow2(m_textureWidth);
m_textureHeight = PadPow2(m_textureHeight);
}
+#endif
if (m_format & XB_FMT_DXT_MASK)
{ // DXT textures must be a multiple of 4 in width and height
m_textureWidth = ((m_textureWidth + 3) / 4) * 4;
@@ -249,12 +251,32 @@ bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned
if (autoRotate && omx_image.GetOrientation())
m_orientation = omx_image.GetOrientation() - 1;
- if(omx_image.GetDecodedData())
+ if(m_textureWidth != omx_image.GetDecodedWidth() || m_textureHeight != omx_image.GetDecodedHeight())
+ {
+ unsigned int imagePitch = GetPitch(m_imageWidth);
+ unsigned int imageRows = GetRows(m_imageHeight);
+ unsigned int texturePitch = GetPitch(m_textureWidth);
+ unsigned int textureRows = GetRows(m_textureHeight);
+ unsigned int blockSize = GetBlockSize();
+
+ unsigned char *src = omx_image.GetDecodedData();
+ unsigned char *dst = m_pixels;
+ for (unsigned int y = 0; y < imageRows; y++)
+ {
+ memcpy(dst, src, imagePitch);
+ src += imagePitch;
+ dst += texturePitch;
+ }
+ }
+ else
{
- int size = ( ( GetPitch() * GetRows() ) > omx_image.GetDecodedSize() ) ?
- omx_image.GetDecodedSize() : ( GetPitch() * GetRows() );
+ if(omx_image.GetDecodedData())
+ {
+ int size = ( ( GetPitch() * GetRows() ) > omx_image.GetDecodedSize() ) ?
+ omx_image.GetDecodedSize() : ( GetPitch() * GetRows() );
- memcpy(m_pixels, (unsigned char *)omx_image.GetDecodedData(), size);
+ memcpy(m_pixels, (unsigned char *)omx_image.GetDecodedData(), size);
+ }
}
omx_image.Close();

0 comments on commit a68f8fc

Please sign in to comment.
Something went wrong with that request. Please try again.