Debian Codegraph @

third_party/etc2comp/EtcTool/EtcSourceImage.h

raw
1 /*
2 * Copyright 2015 The Etc2Comp Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #pragma once
18
19 #include "EtcColorFloatRGBA.h"
20
21 namespace Etc
22 {
23
24 class SourceImage
25 {
26 public:
27
28 SourceImage(const char *a_pstrFilename, int a_iPixelX = -1, int a_iPixelY = -1);
29
30 SourceImage(ColorFloatRGBA *a_pafrgbaSource,
31 unsigned int a_uiSourceWidth,
32 unsigned int a_uiSourceHeight);
33
34 ~SourceImage();
35
36 void SetName(const char *a_pstrFilename);
37
38 void NormalizeXYZ(void);
39
40 inline const char *GetFilename(void)
41 {
42 return m_pstrFilename;
43 }
44
45 inline const char *GetName(void)
46 {
47 return m_pstrName;
48 }
49
50 inline const char *GetFileExtension(void)
51 {
52 return m_pstrFileExtension;
53 }
54
55 inline unsigned int GetWidth(void)
56 {
57 return m_uiWidth;
58 }
59
60 inline unsigned int GetHeight(void)
61 {
62 return m_uiHeight;
63 }
64
65 inline ColorFloatRGBA * GetPixels(void)
66 {
67 return m_pafrgbaPixels;
68 }
69
70 inline ColorFloatRGBA * GetPixel(unsigned int a_uiColumn, unsigned int a_uiRow)
71 {
72 if (m_pafrgbaPixels == nullptr)
73 {
74 return nullptr;
75 }
76
77 return &m_pafrgbaPixels[a_uiRow*m_uiWidth + a_uiColumn];
78 }
79
80 private:
81
82 void Read(int a_iPixelX = -1, int a_iPixelY = -1);
83
84 char *m_pstrFilename; // includes directory path and file extension
85 char *m_pstrName; // file name with directory path and file extension removed
86 char *m_pstrFileExtension;
87 unsigned int m_uiWidth; // not necessarily block aligned
88 unsigned int m_uiHeight; // not necessarily block aligned
89 ColorFloatRGBA *m_pafrgbaPixels;
90
91 };
92
93 } // namespace Etc