3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "utils/StdString.h"
22 #include "utils/Job.h"
29 static bool CreateThumbnailFromSurface(const unsigned char* buffer, int width, int height, int stride, const CStdString &thumbFile);
31 /*! \brief Create a tiled thumb of the given files
32 \param files the files to create the thumb from
33 \param thumb the filename of the thumb
35 static bool CreateTiledThumb(const std::vector<std::string> &files, const std::string &thumb);
37 /*! \brief Cache a texture, resizing, rotating and flipping as needed, and saving as a JPG or PNG
38 \param texture a pointer to a CBaseTexture
39 \param dest_width [in/out] maximum width in pixels of cached version - replaced with actual cached width
40 \param dest_height [in/out] maximum height in pixels of cached version - replaced with actual cached height
41 \param dest the output cache file
42 \return true if successful, false otherwise
44 static bool CacheTexture(CBaseTexture *texture, uint32_t &dest_width, uint32_t &dest_height, const std::string &dest);
45 static bool CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, uint32_t pitch, int orientation, uint32_t &dest_width, uint32_t &dest_height, const std::string &dest);
48 static void GetScale(unsigned int width, unsigned int height, unsigned int &out_width, unsigned int &out_height);
49 static bool ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned int in_height, unsigned int in_pitch,
50 uint8_t *out_pixels, unsigned int out_width, unsigned int out_height, unsigned int out_pitch);
51 static bool OrientateImage(uint32_t *&pixels, unsigned int &width, unsigned int &height, int orientation);
53 static bool FlipHorizontal(uint32_t *&pixels, unsigned int &width, unsigned int &height);
54 static bool FlipVertical(uint32_t *&pixels, unsigned int &width, unsigned int &height);
55 static bool Rotate90CCW(uint32_t *&pixels, unsigned int &width, unsigned int &height);
56 static bool Rotate270CCW(uint32_t *&pixels, unsigned int &width, unsigned int &height);
57 static bool Rotate180CCW(uint32_t *&pixels, unsigned int &width, unsigned int &height);
58 static bool Transpose(uint32_t *&pixels, unsigned int &width, unsigned int &height);
59 static bool TransposeOffAxis(uint32_t *&pixels, unsigned int &width, unsigned int &height);
62 //this class calls CreateThumbnailFromSurface in a CJob, so a png file can be written without halting the render thread
63 class CThumbnailWriter : public CJob
66 //WARNING: buffer is deleted from DoWork()
67 CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const CStdString& thumbFile);
71 unsigned char* m_buffer;
75 CStdString m_thumbFile;