diff --git a/xbmc/pictures/Picture.cpp b/xbmc/pictures/Picture.cpp index 986d2a7773417..045120fcd11fd 100644 --- a/xbmc/pictures/Picture.cpp +++ b/xbmc/pictures/Picture.cpp @@ -29,6 +29,7 @@ #include "utils/log.h" #include "utils/URIUtils.h" #include "DllSwScale.h" +#include "guilib/JpegIO.h" #include "guilib/Texture.h" using namespace XFILE; @@ -48,8 +49,8 @@ bool CPicture::CacheImage(const CStdString& sourceUrl, const CStdString& destFil { CLog::Log(LOGINFO, "Caching image from: %s to %s with width %i and height %i", sourceUrl.c_str(), destFile.c_str(), width, height); + CJpegIO jpegImage; DllImageLib dll; - if (!dll.Load()) return false; if (URIUtils::IsInternetStream(sourceUrl, true)) { @@ -57,6 +58,12 @@ bool CPicture::CacheImage(const CStdString& sourceUrl, const CStdString& destFil CStdString data; if (http.Get(sourceUrl, data)) { + if (URIUtils::GetExtension(sourceUrl).Equals(".jpg") || URIUtils::GetExtension(sourceUrl).Equals(".tbn")) + { + if (jpegImage.CreateThumbnailFromMemory((unsigned char *)data.c_str(), data.GetLength(), destFile.c_str(), width, height)) + return true; + } + if (!dll.Load()) return false; if (!dll.CreateThumbnailFromMemory((BYTE *)data.c_str(), data.GetLength(), URIUtils::GetExtension(sourceUrl).c_str(), destFile.c_str(), width, height)) { CLog::Log(LOGERROR, "%s Unable to create new image %s from image %s", __FUNCTION__, destFile.c_str(), sourceUrl.c_str()); @@ -67,6 +74,12 @@ bool CPicture::CacheImage(const CStdString& sourceUrl, const CStdString& destFil return false; } + if (URIUtils::GetExtension(sourceUrl).Equals(".jpg") || URIUtils::GetExtension(sourceUrl).Equals(".tbn")) + { + if (jpegImage.CreateThumbnail(sourceUrl, destFile, width, height, g_guiSettings.GetBool("pictures.useexifrotation"))) + return true; + } + if (!dll.Load()) return false; if (!dll.CreateThumbnail(sourceUrl.c_str(), destFile.c_str(), width, height, g_guiSettings.GetBool("pictures.useexifrotation"))) { CLog::Log(LOGERROR, "%s Unable to create new image %s from image %s", __FUNCTION__, destFile.c_str(), sourceUrl.c_str()); @@ -98,6 +111,12 @@ bool CPicture::CacheFanart(const CStdString& sourceUrl, const CStdString& destFi bool CPicture::CreateThumbnailFromMemory(const unsigned char* buffer, int bufSize, const CStdString& extension, const CStdString& thumbFile) { CLog::Log(LOGINFO, "Creating album thumb from memory: %s", thumbFile.c_str()); + if (extension.Equals("jpg") || extension.Equals("tbn")) + { + CJpegIO jpegImage; + if (jpegImage.CreateThumbnailFromMemory((unsigned char*)buffer, bufSize, thumbFile.c_str(), g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize)) + return true; + } DllImageLib dll; if (!dll.Load()) return false; if (!dll.CreateThumbnailFromMemory((BYTE *)buffer, bufSize, extension.c_str(), thumbFile.c_str(), g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize)) @@ -124,6 +143,12 @@ void CPicture::CreateFolderThumb(const CStdString *thumbs, const CStdString &fol bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile) { + if (URIUtils::GetExtension(thumbFile).Equals(".jpg") || URIUtils::GetExtension(thumbFile).Equals(".tbn")) + { + CJpegIO jpegImage; + if (jpegImage.CreateThumbnailFromSurface((BYTE *)buffer, width, height, XB_FMT_A8R8G8B8, stride, thumbFile.c_str())) + return true; + } DllImageLib dll; if (!buffer || !dll.Load()) return false; return dll.CreateThumbnailFromSurface((BYTE *)buffer, width, height, stride, thumbFile.c_str());