Skip to content

Commit

Permalink
adds m_originalWidth/Height to CBaseTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall authored and Jonathan Marshall committed Sep 7, 2012
1 parent 88424c6 commit 72cd5be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xbmc/guilib/Texture.cpp
Expand Up @@ -59,8 +59,8 @@ CBaseTexture::~CBaseTexture()

void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned int format)
{
m_imageWidth = width;
m_imageHeight = height;
m_imageWidth = m_originalWidth = width;
m_imageHeight = m_originalHeight = height;
m_format = format;
m_orientation = 0;

Expand Down Expand Up @@ -383,6 +383,8 @@ void CBaseTexture::LoadFromImage(ImageInfo &image, bool autoRotate)
Allocate(image.width, image.height, XB_FMT_A8R8G8B8);
if (autoRotate && image.exifInfo.Orientation)
m_orientation = image.exifInfo.Orientation - 1;
m_originalWidth = image.originalwidth;
m_originalHeight = image.originalheight;

unsigned int dstPitch = GetPitch();
unsigned int srcPitch = ((image.width + 1)* 3 / 4) * 4; // bitmap row length is aligned to 4 bytes
Expand Down Expand Up @@ -426,8 +428,8 @@ void CBaseTexture::LoadFromImage(ImageInfo &image, bool autoRotate)

bool CBaseTexture::LoadFromMemory(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, bool hasAlpha, unsigned char* pixels)
{
m_imageWidth = width;
m_imageHeight = height;
m_imageWidth = m_originalWidth = width;
m_imageHeight = m_originalHeight = height;
m_format = format;
m_hasAlpha = hasAlpha;
Update(width, height, pitch, format, pixels, false);
Expand Down
7 changes: 7 additions & 0 deletions xbmc/guilib/Texture.h
Expand Up @@ -91,6 +91,11 @@ class CBaseTexture
unsigned int GetTextureHeight() const { return m_textureHeight; }
unsigned int GetWidth() const { return m_imageWidth; }
unsigned int GetHeight() const { return m_imageHeight; }
/*! \brief return the original width of the image, before scaling/cropping */
unsigned int GetOriginalWidth() const { return m_originalWidth; }
/*! \brief return the original height of the image, before scaling/cropping */
unsigned int GetOriginalHeight() const { return m_originalHeight; }

int GetOrientation() const { return m_orientation; }
void SetOrientation(int orientation) { m_orientation = orientation; }

Expand Down Expand Up @@ -118,6 +123,8 @@ class CBaseTexture
unsigned int m_imageHeight;
unsigned int m_textureWidth;
unsigned int m_textureHeight;
unsigned int m_originalWidth; ///< original image width before scaling or cropping
unsigned int m_originalHeight; ///< original image height before scaling or cropping

unsigned char* m_pixels;
bool m_loadedToGPU;
Expand Down

0 comments on commit 72cd5be

Please sign in to comment.