File indexing completed on 2025-01-18 10:04:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _Image_Texture_HeaderFile
0016 #define _Image_Texture_HeaderFile
0017
0018 #include <NCollection_Buffer.hxx>
0019 #include <TCollection_AsciiString.hxx>
0020
0021 class Image_CompressedPixMap;
0022 class Image_SupportedFormats;
0023 class Image_PixMap;
0024
0025
0026
0027 class Image_Texture : public Standard_Transient
0028 {
0029 DEFINE_STANDARD_RTTIEXT(Image_Texture, Standard_Transient)
0030 public:
0031
0032
0033 Standard_EXPORT explicit Image_Texture (const TCollection_AsciiString& theFileName);
0034
0035
0036 Standard_EXPORT explicit Image_Texture (const TCollection_AsciiString& theFileName,
0037 int64_t theOffset,
0038 int64_t theLength);
0039
0040
0041 Standard_EXPORT explicit Image_Texture (const Handle(NCollection_Buffer)& theBuffer,
0042 const TCollection_AsciiString& theId);
0043
0044
0045 const TCollection_AsciiString& TextureId() const { return myTextureId; }
0046
0047
0048 const TCollection_AsciiString& FilePath() const { return myImagePath; }
0049
0050
0051 int64_t FileOffset() const { return myOffset; }
0052
0053
0054 int64_t FileLength() const { return myLength; }
0055
0056
0057 const Handle(NCollection_Buffer)& DataBuffer() const { return myBuffer; }
0058
0059
0060 Standard_EXPORT TCollection_AsciiString MimeType() const;
0061
0062
0063 Standard_EXPORT TCollection_AsciiString ProbeImageFileFormat() const;
0064
0065
0066 Standard_EXPORT virtual Handle(Image_CompressedPixMap) ReadCompressedImage (const Handle(Image_SupportedFormats)& theSupported) const;
0067
0068
0069 Standard_EXPORT virtual Handle(Image_PixMap) ReadImage (const Handle(Image_SupportedFormats)& theSupported) const;
0070
0071
0072 Standard_EXPORT virtual Standard_Boolean WriteImage (const TCollection_AsciiString& theFile);
0073
0074
0075 Standard_EXPORT virtual Standard_Boolean WriteImage (std::ostream& theStream,
0076 const TCollection_AsciiString& theFile);
0077
0078 public:
0079
0080
0081 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0082
0083 protected:
0084
0085
0086 Standard_EXPORT virtual Handle(Image_PixMap) loadImageFile (const TCollection_AsciiString& thePath) const;
0087
0088
0089 Standard_EXPORT virtual Handle(Image_PixMap) loadImageOffset (const TCollection_AsciiString& thePath,
0090 int64_t theOffset,
0091 int64_t theLength) const;
0092
0093
0094 Standard_EXPORT virtual Handle(Image_PixMap) loadImageBuffer (const Handle(NCollection_Buffer)& theBuffer,
0095 const TCollection_AsciiString& theId) const;
0096
0097 protected:
0098
0099 TCollection_AsciiString myTextureId;
0100 TCollection_AsciiString myImagePath;
0101 Handle(NCollection_Buffer) myBuffer;
0102 int64_t myOffset;
0103 int64_t myLength;
0104
0105 };
0106
0107 namespace std
0108 {
0109 template<>
0110 struct equal_to<Handle(Image_Texture)>
0111 {
0112 bool operator()(const Handle(Image_Texture)& theTex1,
0113 const Handle(Image_Texture)& theTex2) const
0114 {
0115 if (theTex1.IsNull() != theTex2.IsNull())
0116 {
0117 return Standard_False;
0118 }
0119 else if (theTex1.IsNull())
0120 {
0121 return Standard_True;
0122 }
0123 return theTex1->TextureId().IsEqual(theTex2->TextureId());
0124 }
0125 };
0126
0127 template<>
0128 struct hash<Handle(Image_Texture)>
0129 {
0130 size_t operator()(const Handle(Image_Texture)& theTexture) const noexcept
0131 {
0132 return !theTexture.IsNull()
0133 ? std::hash<TCollection_AsciiString>{}(theTexture->TextureId())
0134 : 0;
0135 }
0136 };
0137 }
0138
0139 #endif