My Project
ImageEntity.h
1 #pragma once
2 #include "AssetEntity.h"
3 
4 namespace ParaEngine
5 {
9  class ImageEntity : public AssetEntity
10  {
11  public:
12  ImageEntity();
13  virtual ~ImageEntity();
14 
15  virtual AssetEntity::AssetType GetType(){ return AssetEntity::image; };
16  public:
22  bool LoadFromFile(const std::string& path);
23 
31  bool LoadFromMemory(const unsigned char * data, size_t dataLen, bool bOwnData = true);
32 
34  bool LoadFromRawData(const unsigned char * data, size_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);
35 
36  // Getters
37  inline unsigned char * getData() { return _data; }
38  inline size_t getDataLen() { return _dataLen; }
39  inline DWORD getFileType() { return _fileType; }
40  inline D3DFORMAT getRenderFormat() { return _renderFormat; }
41  inline int getWidth() { return _width; }
42  inline int getHeight() { return _height; }
43  inline int getNumberOfMipmaps() { return _numberOfMipmaps; }
44  inline bool hasPremultipliedAlpha() { return false; }
45 
46  int getBitPerPixel();
47  bool hasAlpha();
48  bool isCompressed();
49 
55  bool SaveToFile(const std::string &filename, bool isToRGB = true);
56 
57  protected:
60  unsigned char *_data;
61  size_t _dataLen;
62  int _width;
63  int _height;
64  bool _unpack;
65  DWORD _fileType;
66  D3DFORMAT _renderFormat;
67  int _numberOfMipmaps;
68  bool _hasPremultipliedAlpha;
69  std::string _filePath;
70  };
71 }
72 
73 
AssetType
each asset type has a unique asset type number
Definition: AssetEntity.h:82
different physics engine has different winding order.
Definition: EventBinding.h:32
bool LoadFromFile(const std::string &path)
Load the image from the specified path.
Definition: ImageEntity.cpp:40
bool SaveToFile(const std::string &filename, bool isToRGB=true)
Save Image data to the specified file, with specified format.
Definition: ImageEntity.cpp:99
bool m_bIsOwnData
whether we own the data buffer
Definition: ImageEntity.h:59
bool LoadFromRawData(const unsigned char *data, size_t dataLen, int width, int height, int bitsPerComponent, bool preMulti=false)
currently only support RGBA8 32bits data, such as from render target
Definition: ImageEntity.cpp:71
Unlike TextureEntity, ImageEntity is a device independent entity in memory.
Definition: ImageEntity.h:9
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
bool LoadFromMemory(const unsigned char *data, size_t dataLen, bool bOwnData=true)
Load image from stream buffer.
Definition: ImageEntity.cpp:45