ArcGIS Procedural Runtime  3.2.10650
Texture.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_ITEXTURE_H_
19 #define PRTX_ITEXTURE_H_
20 
21 #include "prtx/prtx.h"
22 #include "prtx/URI.h"
23 #include "prtx/Attributable.h"
24 #include "prtx/Content.h"
25 
26 #ifdef _MSC_VER
27 # pragma warning(push)
28 # pragma warning(disable : 4275 4251)
29 #endif
30 
31 #include <memory>
32 
33 
34 namespace prtx {
35 
36 
37 class Texture;
38 typedef std::shared_ptr<Texture> TexturePtr;
39 typedef std::vector<TexturePtr> TexturePtrVector;
40 
41 
59 class PRTX_EXPORTS_API Texture : public Attributable, public ComparableContent {
60 protected:
61  Texture();
62 
63 public:
64  virtual ~Texture();
65 
69  enum PixelFormat {
70  GREY8 = 1,
71  GREY16 = 2,
72  RGB8 = 3,
73  RGBA8 = 4,
74  FLOAT32 = 5,
75  };
76 
77  static const std::wstring METADATA_KEY_WIDTH;
78  static const std::wstring METADATA_KEY_HEIGHT;
79  static const std::wstring METADATA_KEY_BYTESPERPIXEL;
80  static const std::wstring METADATA_KEY_FORMAT;
81 
82  static const std::wstring METADATA_KEY_OFFSET;
83  static const std::wstring METADATA_KEY_SCALE;
84  static const std::wstring METADATA_KEY_NODATAVALUE;
85  static const std::wstring METADATA_KEY_GEOTRANSFORM;
86  static const std::wstring METADATA_KEY_UNIT;
87  static const std::wstring METADATA_KEY_PROJECTIONREF;
88 
89  // deprecated, do not use anymore
90  static const std::wstring METADATA_KEY_DEPTH;
91 
92  static const double METADATA_NODATAVALUE_NONE;
93 
98  static uint8_t getBytesPerPixel(PixelFormat format);
103  static uint8_t getChannelCount(PixelFormat format);
108  static bool hasAlpha(PixelFormat format);
113  template<typename S> static S getFormatAsString(PixelFormat format);
119  static PixelFormat getFormatFromString(const wchar_t* string);
120 
121 
125  virtual prtx::URIPtr getURI() const = 0;
126 
130  virtual bool isValid() const = 0;
131 
135  virtual const uint8_t* getBuffer() const = 0;
139  virtual size_t getBufferSize() const = 0;
140 
144  virtual uint32_t getWidth() const = 0;
148  virtual uint32_t getHeight() const = 0;
152  virtual PixelFormat getFormat() const = 0;
153 
157  virtual const std::wstring& getWarnings() const = 0;
158 };
159 
160 
161 template<> PRTX_EXPORTS_API std::wstring Texture::getFormatAsString<std::wstring>(PixelFormat format);
162 template<> PRTX_EXPORTS_API std::string Texture::getFormatAsString<std::string>(PixelFormat format);
163 
164 
169 class PRTX_EXPORTS_API TextureBuilder : public AttributableSetter {
170 public:
171  TextureBuilder();
172  TextureBuilder(const TextureBuilder&) = delete;
173  TextureBuilder& operator=(const TextureBuilder&) = delete;
174  virtual ~TextureBuilder();
175 
185  TexturePtr createTexture(const prtx::URIPtr& uri, uint32_t width, uint32_t height, const Texture::PixelFormat& format, uint8_t* buffer);
195  TexturePtr createTextureAndReset(const prtx::URIPtr& uri, uint32_t width, uint32_t height, const Texture::PixelFormat& format, uint8_t* buffer);
196 
197  virtual void setBool (const std::wstring& key, Bool val);
198  virtual void setInt (const std::wstring& key, int32_t val);
199  virtual void setFloat (const std::wstring& key, double val);
200  virtual void setString (const std::wstring& key, const std::wstring& val);
201 
202  virtual void setBoolArray (const std::wstring& key, const std::vector<Bool>& val);
203  virtual void setIntArray (const std::wstring& key, const std::vector<int>& val);
204  virtual void setFloatArray (const std::wstring& key, const std::vector<double>& val);
205  virtual void setStringArray (const std::wstring& key, const WStringVector& val);
206 
207  virtual void setBlindData (const std::wstring& key, void* val);
208 
209 private:
210  void* mPrivateData;
211 };
212 
213 
214 } /* namespace prtx */
215 
216 
217 #ifdef _MSC_VER
218 # pragma warning(pop)
219 #endif
220 
221 
222 #endif /* PRTX_ITEXTURE_H_ */
static const std::wstring METADATA_KEY_NODATAVALUE
metadata attribute "noDataValue"
Definition: Texture.h:84
uint8_t Bool
uint8_t based Bool type
Definition: Types.h:30
std::shared_ptr< Texture > TexturePtr
shared Texture pointer
Definition: Texture.h:37
static const std::wstring METADATA_KEY_HEIGHT
metadata attribute "height" (PT_INT), corresponds to getHeight()
Definition: Texture.h:78
Definition: /Attributable.h:37
std::vector< TexturePtr > TexturePtrVector
vector of shared Texture pointers
Definition: Texture.h:39
Definition: Texture.h:59
static const std::wstring METADATA_KEY_DEPTH
(deprecated) metadata attribute "depth" (PT_INT), corresponds to getBytesPerPixel() ...
Definition: Texture.h:90
static const std::wstring METADATA_KEY_OFFSET
metadata attribute "offset"
Definition: Texture.h:82
Definition: /Attributable.h:139
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
std::shared_ptr< URI > URIPtr
shared pointer implementation of prtx::URI
Definition: URI.h:37
static const std::wstring METADATA_KEY_UNIT
metadata attribute "unit"
Definition: Texture.h:86
static const std::wstring METADATA_KEY_WIDTH
metadata attribute "width" (PT_INT), corresponds to getWidth()
Definition: Texture.h:77
Definition: Content.h:88
static const std::wstring METADATA_KEY_PROJECTIONREF
metadata attribute "projectionRef"
Definition: Texture.h:87
static const std::wstring METADATA_KEY_BYTESPERPIXEL
metadata attribute "bytesPerPixel" (PT_INT), corresponds to getBytesPerPixel()
Definition: Texture.h:79
Definition: Texture.h:169
static const std::wstring METADATA_KEY_FORMAT
metadata attribute "format" (PT_STRING), i.e. PixelFormat as wstring
Definition: Texture.h:80
static const std::wstring METADATA_KEY_GEOTRANSFORM
metadata attribute "geoTransform", see GDALDataset::GetGeoTransform() documentation ...
Definition: Texture.h:85
static const double METADATA_NODATAVALUE_NONE
sentinel value for the METADATA_KEY_NODATAVALUE attribute = "there is *no* noDataValue").
Definition: Texture.h:92
std::vector< std::wstring > WStringVector
vector of std::wstring
Definition: Types.h:35
static const std::wstring METADATA_KEY_SCALE
metadata attribute "scale"
Definition: Texture.h:83
PixelFormat
Definition: Texture.h:69