Permalink
Browse files

jpeg: pass the desired dimensions into the jpeg decoder.

  • Loading branch information...
theuni
theuni committed Dec 7, 2011
1 parent 03f2eb6 commit adcc5689039b9d431aa3d7d7ed9367083183c289
Showing with 20 additions and 4 deletions.
  1. +12 −2 xbmc/guilib/JpegIO.cpp
  2. +3 −1 xbmc/guilib/JpegIO.h
  3. +5 −1 xbmc/guilib/Texture.cpp
View
@@ -134,6 +134,8 @@ CJpegIO::CJpegIO()
m_imgsize = 0;
m_width = 0;
m_height = 0;
+ m_original_width = 0;
+ m_original_height = 0;
m_orientation = 0;
m_inputBuffSize = 0;
m_inputBuff = NULL;
@@ -150,7 +152,7 @@ void CJpegIO::Close()
delete [] m_inputBuff;
}
-bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned int miny)
+bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned int miny, unsigned int *original_width, unsigned int *original_height)
{
m_texturePath = texturePath;
m_minx = minx;
@@ -201,6 +203,12 @@ bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned in
m_minx = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth;
m_miny = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight;
}
+ m_original_width = m_cinfo.image_width;
+ m_original_height = m_cinfo.image_height;
+ if (original_width)
+ *original_width = m_original_width;
+ if (original_height)
+ *original_height = m_original_height;
m_cinfo.scale_denom = 8;
m_cinfo.out_color_space = JCS_RGB;
unsigned int maxtexsize = g_Windowing.GetMaxTextureSize();
@@ -218,7 +226,9 @@ bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned in
jpeg_calc_output_dimensions(&m_cinfo);
m_width = m_cinfo.output_width;
m_height = m_cinfo.output_height;
-
+ if (m_original_width > m_width || m_original_height > m_height)
+ CLog::Log(LOGNOTICE, "JpegIO: %s: Full size: %ix%i. Only decoding: %ix%i for output size: %ix%i",
+ texturePath.c_str(), m_original_width, m_original_height, m_width, m_height, minx, miny);
GetExif();
return true;
}
View
@@ -36,7 +36,7 @@ class CJpegIO
public:
CJpegIO();
~CJpegIO();
- bool Open(const CStdString& m_texturePath, unsigned int m_minx=0, unsigned int m_miny=0);
+ bool Open(const CStdString& m_texturePath, unsigned int m_minx=0, unsigned int m_miny=0, unsigned int *original_width=NULL, unsigned int *original_height=NULL);
bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format);
void Close();
@@ -63,6 +63,8 @@ class CJpegIO
unsigned int m_width;
unsigned int m_height;
unsigned int m_orientation;
+ unsigned int m_original_width;
+ unsigned int m_original_height;
};
#endif
View
@@ -174,7 +174,7 @@ bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxW
if (URIUtils::GetExtension(texturePath).Equals(".jpg") || URIUtils::GetExtension(texturePath).Equals(".tbn"))
{
CJpegIO jpegfile;
- if (jpegfile.Open(texturePath))
+ if (jpegfile.Open(texturePath, maxWidth, maxHeight, &m_originalImageWidth, &m_originalImageHeight))
{
if (jpegfile.Width() > 0 && jpegfile.Height() > 0)
{
@@ -184,6 +184,10 @@ bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxW
if (autoRotate && jpegfile.Orientation())
m_orientation = jpegfile.Orientation() - 1;
m_hasAlpha=false;
+ if (originalWidth)
+ *originalWidth = m_originalImageWidth;
+ if (originalHeight)
+ *originalHeight = m_originalImageHeight;
return true;
}
}

0 comments on commit adcc568

Please sign in to comment.