24 #ifndef PXR_IMAGING_HIO_IMAGE_H
25 #define PXR_IMAGING_HIO_IMAGE_H
30 #include "pxr/imaging/hio/api.h"
31 #include "pxr/imaging/hio/types.h"
34 #include "pxr/base/tf/type.h"
36 #include "pxr/base/vt/value.h"
41 PXR_NAMESPACE_OPEN_SCOPE
44 using HioImageSharedPtr = std::shared_ptr<class HioImage>;
83 : width(0), height(0), depth(0)
84 , format(HioFormatInvalid)
88 int width, height, depth;
115 static HioImageSharedPtr
OpenForReading(std::string
const & filename,
119 SourceColorSpace::Auto,
120 bool suppressErrors =
false);
127 int const cropBottom,
139 static HioImageSharedPtr
OpenForWriting(std::string
const & filename);
148 virtual std::string
const &
GetFilename()
const = 0;
170 template <
typename T>
171 bool GetMetadata(
TfToken const & key, T * value)
const;
173 virtual bool GetMetadata(
TfToken const & key,
VtValue * value)
const = 0;
175 virtual bool GetSamplerMetadata(HioAddressDimension dim,
176 HioAddressMode * param)
const = 0;
185 bool suppressErrors) = 0;
187 virtual bool _OpenForWriting(std::string
const & filename) = 0;
190 template <
typename T>
192 HioImage::GetMetadata(
TfToken const & key, T * value)
const
195 if (!GetMetadata(key, &any) || !any.
IsHolding<T>()) {
204 virtual HioImageSharedPtr New()
const = 0;
208 class HioImageFactory :
public HioImageFactoryBase {
210 virtual HioImageSharedPtr New()
const
212 return HioImageSharedPtr(
new T);
217 PXR_NAMESPACE_CLOSE_SCOPE
219 #endif // PXR_IMAGING_HIO_IMAGE_H
static HIO_API bool IsSupportedImageFile(std::string const &filename)
Returns whether filename opened as a texture image.
virtual HioFormat GetFormat() const =0
Returns the destination HioFormat.
T const & UncheckedGet() const
Returns a const reference to the held object if the held object is of type T.
static HIO_API HioImageSharedPtr OpenForWriting(std::string const &filename)
Opens filename for writing from the given storage.
A map with string keys and VtValue values.
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
virtual int GetHeight() const =0
Returns the image height.
virtual bool _OpenForReading(std::string const &filename, int subimage, int mip, SourceColorSpace sourceColorSpace, bool suppressErrors)=0
}@
virtual std::string const & GetFilename() const =0
}@
Base class of all factory types.
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
virtual bool ReadCropped(int const cropTop, int const cropBottom, int const cropLeft, int const cropRight, StorageSpec const &storage)=0
Reads the cropped sub-image into storage.
SourceColorSpace
Specifies the source color space in which the texture is encoded, with "Auto" indicating the texture ...
Token for efficient comparison, assignment, and hashing of known strings.
Describes the memory layout and storage of a texture image.
static HIO_API HioImageSharedPtr OpenForReading(std::string const &filename, int subimage=0, int mip=0, SourceColorSpace sourceColorSpace=SourceColorSpace::Auto, bool suppressErrors=false)
Opens filename for reading from the given subimage at mip level mip, using sourceColorSpace to help d...
virtual int GetNumMipLevels() const =0
Returns the number of mips available.
virtual bool IsColorSpaceSRGB() const =0
Returns whether the image is in the sRGB color space.
virtual bool Read(StorageSpec const &storage)=0
Reads the image file into storage.
virtual int GetBytesPerPixel() const =0
Returns the number of bytes per pixel.
virtual int GetWidth() const =0
Returns the image width.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
A base class for reading and writing texture image data.
virtual bool Write(StorageSpec const &storage, VtDictionary const &metadata=VtDictionary())=0
Writes the image with metadata.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...