Add Image::sampleFormatEnum<T>()
This commit is contained in:
@@ -160,6 +160,8 @@ public:
|
||||
static PixelStorage pixelStorageEnum(const QString &storage);
|
||||
static QString pixelStorageString(PixelStorage storage);
|
||||
static SampleFormat sampleFormatEnum(const QString &format);
|
||||
template<typename T>
|
||||
static SampleFormat sampleFormatEnum();
|
||||
static QString sampleFormatString(SampleFormat format);
|
||||
static ColorSpace colorSpaceEnum(const QString &colorSpace);
|
||||
static QString colorSpaceString(ColorSpace colorSpace);
|
||||
@@ -302,6 +304,19 @@ public:
|
||||
const char* what() const noexcept { return _msg.c_str(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
Image::SampleFormat Image::sampleFormatEnum()
|
||||
{
|
||||
if(std::is_same<T, LibXISF::UInt8>::value)return Image::UInt8;
|
||||
if(std::is_same<T, LibXISF::UInt16>::value)return Image::UInt16;
|
||||
if(std::is_same<T, LibXISF::UInt32>::value)return Image::UInt32;
|
||||
if(std::is_same<T, LibXISF::UInt64>::value)return Image::UInt64;
|
||||
if(std::is_same<T, LibXISF::Float32>::value)return Image::Float32;
|
||||
if(std::is_same<T, LibXISF::Float64>::value)return Image::Float64;
|
||||
if(std::is_same<T, LibXISF::Complex32>::value)return Image::Complex32;
|
||||
if(std::is_same<T, LibXISF::Complex64>::value)return Image::Complex64;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(LibXISF::Boolean);
|
||||
|
||||
+2
-2
@@ -11,10 +11,10 @@ void benchmarkType(float avg, float stdDev)
|
||||
std::mt19937 gen;
|
||||
std::normal_distribution<float> normalDist {avg, stdDev};
|
||||
|
||||
Image image(2048, 2048);
|
||||
Image image(2048, 2048, 1, Image::sampleFormatEnum<T>());
|
||||
UInt32 pixels = 2048*2048;
|
||||
UInt32 size = pixels*sizeof(T);
|
||||
T *ptr = (T*)image.imageData();
|
||||
T *ptr = image.imageData<T>();
|
||||
for(UInt32 i=0; i < pixels; i++)
|
||||
{
|
||||
ptr[i] = normalDist(gen);
|
||||
|
||||
Reference in New Issue
Block a user