faff3767 |
1 | // Copyright (c) 2020 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _Image_CompressedPixMap_HeaderFile |
15 | #define _Image_CompressedPixMap_HeaderFile |
16 | |
17 | #include <Image_Format.hxx> |
18 | #include <Image_CompressedFormat.hxx> |
19 | #include <NCollection_Array1.hxx> |
20 | #include <NCollection_Buffer.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | //! Compressed pixmap data definition. |
24 | //! It is defined independently from Image_PixMap, which defines only uncompressed formats. |
25 | class Image_CompressedPixMap : public Standard_Transient |
26 | { |
27 | DEFINE_STANDARD_RTTIEXT(Image_CompressedPixMap, Standard_Transient) |
28 | public: |
29 | |
30 | //! Return base (uncompressed) pixel format. |
31 | Image_Format BaseFormat() const { return myBaseFormat; } |
32 | |
33 | //! Set base (uncompressed) pixel format. |
34 | void SetBaseFormat (Image_Format theFormat) { myBaseFormat = theFormat; } |
35 | |
36 | //! Return compressed format. |
37 | Image_CompressedFormat CompressedFormat() const { return myFormat; } |
38 | |
39 | //! Set compressed format. |
40 | void SetCompressedFormat (Image_CompressedFormat theFormat) { myFormat = theFormat; } |
41 | |
42 | //! Return raw (compressed) data. |
43 | const Handle(NCollection_Buffer)& FaceData() const { return myFaceData; } |
44 | |
45 | //! Set raw (compressed) data. |
46 | void SetFaceData (const Handle(NCollection_Buffer)& theBuffer) { myFaceData = theBuffer; } |
47 | |
48 | //! Return Array of mipmap sizes, including base level. |
49 | const NCollection_Array1<Standard_Integer>& MipMaps() const { return myMipMaps; } |
50 | |
51 | //! Return Array of mipmap sizes, including base level. |
52 | NCollection_Array1<Standard_Integer>& ChangeMipMaps() { return myMipMaps; } |
53 | |
54 | //! Return TRUE if complete mip map level set (up to 1x1 resolution). |
55 | Standard_Boolean IsCompleteMipMapSet() const { return myIsCompleteMips; } |
56 | |
57 | //! Set if complete mip map level set (up to 1x1 resolution). |
58 | void SetCompleteMipMapSet (Standard_Boolean theIsComplete) { myIsCompleteMips = theIsComplete; } |
59 | |
60 | //! Return surface length in bytes. |
61 | Standard_Size FaceBytes() const { return myFaceBytes; } |
62 | |
63 | //! Set surface length in bytes. |
64 | void SetFaceBytes (Standard_Size theSize) { myFaceBytes = theSize; } |
65 | |
66 | //! Return surface width. |
67 | Standard_Integer SizeX() const { return mySizeX; } |
68 | |
69 | //! Return surface height. |
70 | Standard_Integer SizeY() const { return mySizeY; } |
71 | |
72 | //! Set surface width x height. |
73 | void SetSize (Standard_Integer theSizeX, Standard_Integer theSizeY) |
74 | { |
75 | mySizeX = theSizeX; |
76 | mySizeY = theSizeY; |
77 | } |
78 | |
79 | //! Return TRUE if image layout is top-down (always true). |
80 | bool IsTopDown() const { return true; } |
81 | |
82 | //! Return number of faces in the file; should be 6 for cubemap. |
83 | Standard_Integer NbFaces() const { return myNbFaces; } |
84 | |
85 | //! Set number of faces in the file. |
86 | void SetNbFaces (Standard_Integer theSize) { myNbFaces = theSize; } |
87 | |
88 | public: |
89 | |
90 | //! Empty constructor. |
91 | Image_CompressedPixMap() |
92 | : myFaceBytes (0), myNbFaces (0), mySizeX (0), mySizeY (0), myBaseFormat (Image_Format_UNKNOWN), myFormat (Image_CompressedFormat_UNKNOWN), myIsCompleteMips (false) {} |
93 | |
94 | protected: |
95 | |
96 | NCollection_Array1<Standard_Integer> myMipMaps; //!< Array of mipmap sizes, including base level |
97 | Handle(NCollection_Buffer) myFaceData; //!< raw compressed data |
98 | Standard_Size myFaceBytes; //!< surface length in bytes |
99 | Standard_Integer myNbFaces; //!< number of faces in the file |
100 | Standard_Integer mySizeX; //!< surface width |
101 | Standard_Integer mySizeY; //!< surface height |
102 | Image_Format myBaseFormat; //!< base (uncompressed) pixel format |
103 | Image_CompressedFormat myFormat; //!< compressed format |
104 | Standard_Boolean myIsCompleteMips; //!< flag indicating complete mip map level set (up to 1x1 resolution) |
105 | |
106 | }; |
107 | |
108 | #endif // _Image_CompressedPixMap_HeaderFile |