Krita Source Code Documentation
Loading...
Searching...
No Matches
KoColorModelStandardIdsUtils.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KOCOLORMODELSTANDARDIDSUTILS_H
8#define KOCOLORMODELSTANDARDIDSUTILS_H
9
11
12#include <KoConfig.h>
13#ifdef HAVE_OPENEXR
14#include <half.h>
15#endif
16
17
18template <typename channel_type>
20
24
28
29#ifdef HAVE_OPENEXR
30template<> inline KoID colorDepthIdForChannelType<half>() {
32}
33#endif
34
38
42
43template <template <typename T> class Functor,
44 typename... Args,
45 typename Result = decltype(std::declval<Functor<quint8>>()(std::declval<Args>()...))>
46Result channelTypeForColorDepthId(const KoID &depthId, Args... args)
47{
48 if (depthId == Integer8BitsColorDepthID) {
49 return Functor<quint8>()(args...);
50 } else if (depthId == Integer16BitsColorDepthID) {
51 return Functor<quint16>()(args...);
52#ifdef HAVE_OPENEXR
53 } else if (depthId == Float16BitsColorDepthID) {
54 return Functor<half>()(args...);
55#endif
56 } else if (depthId == Float32BitsColorDepthID) {
57 return Functor<float>()(args...);
58 }
59
60 throw std::runtime_error("Invalid bit depth!");
61}
62
63
64#endif // KOCOLORMODELSTANDARDIDSUTILS_H
65
KoID colorDepthIdForChannelType()
KoID colorDepthIdForChannelType< quint16 >()
KoID colorDepthIdForChannelType< quint8 >()
KoID colorDepthIdForChannelType< double >()
KoID colorDepthIdForChannelType< float >()
Result channelTypeForColorDepthId(const KoID &depthId, Args... args)
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
Definition KoID.h:30