Isis Developer Reference
PixelType.h
Go to the documentation of this file.
1#ifndef PixelType_h
2#define PixelType_h
7
8/* SPDX-License-Identifier: CC0-1.0 */
9#include <QString>
10
11#include "gdal_priv.h"
12
13namespace Isis {
40
48 inline int SizeOf(Isis::PixelType pixelType) {
49 if(pixelType == Isis::None) return 0;
50 if(pixelType == Isis::UnsignedByte) return sizeof(unsigned char);
51 if(pixelType == Isis::SignedByte) return sizeof(char);
52 if(pixelType == Isis::UnsignedWord) return sizeof(unsigned short);
53 if(pixelType == Isis::SignedWord) return sizeof(short);
54 if(pixelType == Isis::UnsignedInteger) return sizeof(unsigned int);
55 if(pixelType == Isis::SignedInteger) return sizeof(int);
56 if(pixelType == Isis::Real) return sizeof(float);
57 if(pixelType == Isis::Double) return sizeof(double);
58 return -1;
59 }
60
68 inline QString PixelTypeName(Isis::PixelType pixelType) {
69 if(pixelType == Isis::None) return "None";
70 if(pixelType == Isis::UnsignedByte) return "UnsignedByte";
71 if(pixelType == Isis::SignedByte) return "SignedByte";
72 if(pixelType == Isis::UnsignedWord) return "UnsignedWord";
73 if(pixelType == Isis::SignedWord) return "SignedWord";
74 if(pixelType == Isis::UnsignedInteger) return "UnsignedInteger";
75 if(pixelType == Isis::SignedInteger) return "SignedInteger";
76 if(pixelType == Isis::Real) return "Real";
77 if(pixelType == Isis::Double) return "Double";
78 return "Error";
79 }
80
91 inline Isis::PixelType PixelTypeEnumeration(const QString &type) {
92 QString temp = type.toUpper();
93 if(temp == "UNSIGNEDBYTE" || temp == "8BIT" || temp == "8-BIT") return Isis::UnsignedByte;
94 if(temp == "SIGNEDBYTE") return Isis::SignedByte;
95 if(temp == "UNSIGNEDWORD") return Isis::UnsignedWord;
96 if(temp == "SIGNEDWORD") return Isis::SignedWord;
97 if(temp == "UNSIGNEDINTEGER") return Isis::UnsignedInteger;
98 if(temp == "SIGNEDINTEGER") return Isis::SignedInteger;
99 if(temp == "REAL") return Isis::Real;
100 if(temp == "DOUBLE") return Isis::Double;
101 return Isis::None;
102 }
103
104 inline Isis::PixelType GdalPixelToIsis(GDALDataType type) {
105 if (type == GDT_Byte) return Isis::UnsignedByte;
106 if (type == GDT_Int8) return Isis::SignedByte;
107 if (type == GDT_UInt16) return Isis::UnsignedWord;
108 if (type == GDT_Int16) return Isis::SignedWord;
109 if (type == GDT_UInt32) return Isis::UnsignedInteger;
110 if (type == GDT_Int32) return Isis::SignedInteger;
111 if (type == GDT_Float32) return Isis::Real;
112 if (type == GDT_Float64) return Isis::Double;
113 return Isis::None;
114 }
115
116 inline GDALDataType IsisPixelToGdal(Isis::PixelType type) {
117 if(type == Isis::None) return GDT_Unknown;
118 if(type == Isis::UnsignedByte) return GDT_Byte;
119 if(type == Isis::SignedByte) return GDT_Int8;
120 if(type == Isis::UnsignedWord) return GDT_UInt16;
121 if(type == Isis::SignedWord) return GDT_Int16;
122 if(type == Isis::UnsignedInteger) return GDT_UInt32;
123 if(type == Isis::SignedInteger) return GDT_Int32;
124 if(type == Isis::Real) return GDT_Float32;
125 if(type == Isis::Double) return GDT_Float64;
126 return GDT_Unknown;
127 }
128}
129
130#endif
131
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
Definition PixelType.h:48
Isis::PixelType PixelTypeEnumeration(const QString &type)
Returns PixelType enumeration given a string.
Definition PixelType.h:91
GDALDataType IsisPixelToGdal(Isis::PixelType type)
Definition PixelType.h:116
Isis::PixelType GdalPixelToIsis(GDALDataType type)
Definition PixelType.h:104
QString PixelTypeName(Isis::PixelType pixelType)
Returns string name of PixelType enumeration entered as input parameter.
Definition PixelType.h:68
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:29
@ SignedByte
Definition PixelType.h:32
@ SignedWord
Definition PixelType.h:34
@ SignedInteger
Definition PixelType.h:36
@ UnsignedInteger
Definition PixelType.h:35
@ None
Definition PixelType.h:30
@ UnsignedByte
Definition PixelType.h:31
@ UnsignedWord
Definition PixelType.h:33
@ Double
Definition PixelType.h:38
@ Real
Definition PixelType.h:37