xbmc
iimage.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <string>
12 
13 class IImage
14 {
15 public:
16 
17  virtual ~IImage() = default;
18 
27  virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height)=0;
37  virtual bool Decode(unsigned char* const pixels, unsigned int width, unsigned int height, unsigned int pitch, unsigned int format)=0;
51  virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile,
52  unsigned char* &bufferout, unsigned int &bufferoutSize)=0;
56  virtual void ReleaseThumbnailBuffer() {}
57 
58  unsigned int Width() const { return m_width; }
59  unsigned int Height() const { return m_height; }
60  unsigned int originalWidth() const { return m_originalWidth; }
61  unsigned int originalHeight() const { return m_originalHeight; }
62  unsigned int Orientation() const { return m_orientation; }
63  bool hasAlpha() const { return m_hasAlpha; }
64 
65 protected:
66 
67  unsigned int m_width = 0;
68  unsigned int m_height = 0;
69  unsigned int m_originalWidth = 0;
70  unsigned int m_originalHeight = 0;
71  unsigned int m_orientation = 0;
72  bool m_hasAlpha = false;
73 
74 };
virtual bool LoadImageFromMemory(unsigned char *buffer, unsigned int bufSize, unsigned int width, unsigned int height)=0
Load an image from memory with the format m_strMimeType to determine it&#39;s size and orientation...
virtual bool Decode(unsigned char *const pixels, unsigned int width, unsigned int height, unsigned int pitch, unsigned int format)=0
Decodes the previously loaded image data to the output buffer in 32 bit raw bits. ...
unsigned int m_originalHeight
original image height before scaling or cropping
Definition: iimage.h:70
virtual bool CreateThumbnailFromSurface(unsigned char *bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string &destFile, unsigned char *&bufferout, unsigned int &bufferoutSize)=0
Encodes an thumbnail from raw bits of given memory location.
Definition: iimage.h:13
virtual void ReleaseThumbnailBuffer()
Frees the output buffer allocated by CreateThumbnailFromSurface.
Definition: iimage.h:56
unsigned int m_originalWidth
original image width before scaling or cropping
Definition: iimage.h:69