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"
41PXR_NAMESPACE_OPEN_SCOPE
44using HioImageSharedPtr = std::shared_ptr<class HioImage>;
85 : width(0), height(0), depth(0)
86 , format(HioFormatInvalid)
90 int width, height, depth;
121 SourceColorSpace::Auto,
122 bool suppressErrors =
false);
129 int const cropBottom,
172 template <
typename T>
173 bool GetMetadata(
TfToken const & key, T * value)
const;
175 virtual bool GetMetadata(
TfToken const & key,
VtValue * value)
const = 0;
177 virtual bool GetSamplerMetadata(HioAddressDimension dim,
178 HioAddressMode * param)
const = 0;
187 bool suppressErrors) = 0;
189 virtual bool _OpenForWriting(std::string
const & filename) = 0;
194HioImage::GetMetadata(
TfToken const & key, T * value)
const
197 if (!GetMetadata(key, &any) || !any.
IsHolding<T>()) {
206 virtual HioImageSharedPtr New()
const = 0;
210class HioImageFactory :
public HioImageFactoryBase {
212 virtual HioImageSharedPtr New()
const
214 return HioImageSharedPtr(
new T);
219PXR_NAMESPACE_CLOSE_SCOPE
Describes the memory layout and storage of a texture image.
A base class for reading and writing texture image data.
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.
virtual bool Write(StorageSpec const &storage, VtDictionary const &metadata=VtDictionary())=0
Writes the image with metadata.
virtual bool _OpenForReading(std::string const &filename, int subimage, int mip, SourceColorSpace sourceColorSpace, bool suppressErrors)=0
}@
virtual std::string const & GetFilename() const =0
}@
virtual HioFormat GetFormat() const =0
Returns the destination HioFormat.
virtual int GetNumMipLevels() const =0
Returns the number of mips available.
virtual int GetWidth() const =0
Returns the image width.
virtual int GetBytesPerPixel() const =0
Returns the number of bytes per pixel.
virtual int GetHeight() const =0
Returns the image height.
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 bool Read(StorageSpec const &storage)=0
Reads the image file into storage.
SourceColorSpace
Specifies the source color space in which the texture is encoded, with "Auto" indicating the texture ...
static HIO_API bool IsSupportedImageFile(std::string const &filename)
Returns whether filename opened as a texture image.
static HIO_API HioImageSharedPtr OpenForWriting(std::string const &filename)
Opens filename for writing from the given storage.
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left.
virtual bool IsColorSpaceSRGB() const =0
Returns whether the image is in the sRGB color space.
Token for efficient comparison, assignment, and hashing of known strings.
Base class of all factory types.
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...