Permalink
Browse files

[imageloader] factor out LoadFromImage

  • Loading branch information...
1 parent 58a38d8 commit 55db267497fca66ab6fabd6507611d17094d9b35 Jonathan Marshall committed Jul 1, 2012
Showing with 15 additions and 8 deletions.
  1. +13 −8 xbmc/guilib/Texture.cpp
  2. +2 −0 xbmc/guilib/Texture.h
View
@@ -223,15 +223,24 @@ bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxW
return false;
}
+ if (originalWidth)
+ *originalWidth = image.originalwidth;
+ if (originalHeight)
+ *originalHeight = image.originalheight;
+
+ LoadFromImage(image, autoRotate);
+ dll.ReleaseImage(&image);
+
+ return true;
+}
+
+void CBaseTexture::LoadFromImage(ImageInfo &image, bool autoRotate)
+{
m_hasAlpha = NULL != image.alpha;
Allocate(image.width, image.height, XB_FMT_A8R8G8B8);
if (autoRotate && image.exifInfo.Orientation)
m_orientation = image.exifInfo.Orientation - 1;
- if (originalWidth)
- *originalWidth = image.originalwidth;
- if (originalHeight)
- *originalHeight = image.originalheight;
unsigned int dstPitch = GetPitch();
unsigned int srcPitch = ((image.width + 1)* 3 / 4) * 4; // bitmap row length is aligned to 4 bytes
@@ -270,11 +279,7 @@ bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxW
dst += dstPitch;
}
}
- dll.ReleaseImage(&image);
-
ClampToEdge();
-
- return true;
}
bool CBaseTexture::LoadFromMemory(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, bool hasAlpha, unsigned char* pixels)
View
@@ -33,6 +33,7 @@ struct COLOR {unsigned char b,g,r,x;}; // Windows GDI expects 4bytes per color
class CTexture;
class CGLTexture;
class CDXTexture;
+struct ImageInfo;
/*!
\ingroup textures
@@ -77,6 +78,7 @@ class CBaseTexture
bool SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements = 4, unsigned int offset=0);
protected:
+ void LoadFromImage(ImageInfo &image, bool autoRotate = false);
// helpers for computation of texture parameters for compressed textures
unsigned int GetPitch(unsigned int width) const;
unsigned int GetRows(unsigned int height) const;

0 comments on commit 55db267

Please sign in to comment.