You.i Engine
YiImageDecoder.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_IMAGE_DECODER_H_
3 #define _YI_IMAGE_DECODER_H_
4 
6 #include "utility/YiString.h"
7 
13 class CYIBitmap;
14 
19 {
21  nWidth(-1),
22  nHeight(-1),
23  nTargetDepth(32),
24  pDestBitmap(nullptr),
25  bPremultiplyAlpha(true),
26  eLoadColorMode(CYIImageAssetLoadParams::LOAD_COLOR_MODE_DEFAULT)
27  {}
28 
29  int32_t nWidth;
30  int32_t nHeight;
31  int32_t nTargetDepth;
35 
37 
42 {
43  friend class CYIAssetDecoderImage;
44 public:
45  CYIImageDecoder(bool bIsAnimationSupported, bool bIsPreallocatedBitmapSupported);
46  virtual ~CYIImageDecoder();
47 
51  bool IsAnimationSupported();
52 
56  bool IsPreAllocatedBitmapSupported();
57 
62  virtual bool IsFormatSupported(const uint8_t *pData, uint32_t nDataSize);
63 
68  std::unique_ptr<CYIBitmap> Decode(const uint8_t *pData, uint32_t nDataSize, YI_DECODER_BITMAP_PARAMS *pParams = nullptr);
69 
74  std::unique_ptr<CYIBitmap> Decode(const CYIString &path, YI_DECODER_BITMAP_PARAMS *pParams = nullptr);
75 
80  virtual bool GetImageDimensions(const CYIString &path, uint32_t *pnWidth, uint32_t *pnHeight);
81 
82 protected:
86  virtual std::unique_ptr<CYIBitmap> DecodeImpl(const uint8_t *pData, uint32_t nDataSize, YI_DECODER_BITMAP_PARAMS *pParams) = 0;
87 
91  virtual std::unique_ptr<CYIBitmap> DecodeImpl(const CYIString &path, YI_DECODER_BITMAP_PARAMS *pParams) = 0;
92 
98  void SetMagicByteInformation(uint32_t uMagicByteOffset, const std::vector<const char *> &possibleSequences);
99 
100 private:
101  std::vector<const char *> m_magicByteSequences;
102  uint32_t m_nMagicByteOffset;
103 
104  bool m_bSupportPreallocatedBitmap;
105  bool m_bSupportAnimation;
106 };
107 
110 #endif // _YI_IMAGE_DECODER_H_
Base class for all specialized raster image decoders.
Definition: YiAssetDecoderImage.h:21
_YI_DECODER_BITMAP_PARAMS()
Definition: YiImageDecoder.h:20
int32_t nHeight
Definition: YiImageDecoder.h:30
LOAD_COLOR_MODE
Definition: YiImageAssetLoadParams.h:28
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:35
CYIImageAssetLoadParams::LOAD_COLOR_MODE eLoadColorMode
Definition: YiImageDecoder.h:34
bool bPremultiplyAlpha
Definition: YiImageDecoder.h:33
The core bitmap container class used by You.i Engine.
Definition: YiBitmap.h:20
Asset loading parameters which are specific to image asset decoding.
Definition: YiImageAssetLoadParams.h:22
virtual bool IsFormatSupported(const uint8_t *pData, uint32_t nDataSize) override
int32_t nTargetDepth
Definition: YiImageDecoder.h:31
struct _YI_DECODER_BITMAP_PARAMS YI_DECODER_BITMAP_PARAMS
General container for passing parameters to an image decoder.
int32_t nWidth
Definition: YiImageDecoder.h:29
CYIBitmap * pDestBitmap
Definition: YiImageDecoder.h:32
General container for passing parameters to an image decoder.
Definition: YiImageDecoder.h:18
Raster image decoder base class; all raster image decoders should sub-type this class.
Definition: YiImageDecoder.h:41