Fix keymap.
[vuplus_xbmc] / xbmc / guilib / iimage.h
1 #pragma once
2 /*
3  *      Copyright (C) 2012-2013 Team XBMC
4  *      http://xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21 #include "utils/StdString.h"
22
23 class IImage
24 {
25 public:
26
27   IImage():m_width(0), m_height(0), m_originalWidth(0), m_originalHeight(0), m_orientation(0), m_hasAlpha(false) {};
28   virtual ~IImage() {};
29
30   /*!
31    \brief Load an image from memory with the format m_strMimeType to determine it's size and orientation
32    \param buffer The memory location where the image data can be found
33    \param bufSize The size of the buffer
34    \param width The ideal width of the texture
35    \param height The ideal height of the texture
36    \return true if the image could be loaded
37    */
38   virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height)=0;
39   /*!
40    \brief Decodes the previously loaded image data to the output buffer in 32 bit raw bits
41    \param pixels The output buffer
42    \param pitch The pitch of the output buffer
43    \param format The format of the output buffer (JpegIO only)
44    \return true if the image data could be decoded to the output buffer
45    */
46   virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format)=0;
47   /*!
48    \brief Encodes an thumbnail from raw bits of given memory location
49    \remarks Caller need to call ReleaseThumbnailBuffer() afterwards to free the output buffer
50    \param bufferin The memory location where the image data can be found
51    \param width The width of the thumbnail
52    \param height The height of the thumbnail
53    \param format The format of the input buffer (JpegIO only)
54    \param pitch The pitch of the input texture stored in bufferin
55    \param destFile The destination path of the thumbnail to determine the image format from the extension
56    \param bufferout The output buffer (will be allocated inside the method)
57    \param bufferoutSize The output buffer size
58    \return true if the thumbnail was successfully created
59    */
60   virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, 
61                                           unsigned char* &bufferout, unsigned int &bufferoutSize)=0;
62   /*!
63    \brief Frees the output buffer allocated by CreateThumbnailFromSurface
64    */
65   virtual void ReleaseThumbnailBuffer() {return;}
66
67   unsigned int Width() const              { return m_width; }
68   unsigned int Height() const             { return m_height; }
69   unsigned int originalWidth() const      { return m_originalWidth; }
70   unsigned int originalHeight() const     { return m_originalHeight; }
71   unsigned int Orientation() const        { return m_orientation; }
72   bool hasAlpha() const                   { return m_hasAlpha; }
73
74 protected:
75
76   unsigned int m_width;
77   unsigned int m_height;
78   unsigned int m_originalWidth;   ///< original image width before scaling or cropping
79   unsigned int m_originalHeight;  ///< original image height before scaling or cropping
80   unsigned int m_orientation;
81   bool m_hasAlpha;
82  
83 };