HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfImageChannelRenaming.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_IMAGE_CHANNEL_RENAMING_H
7 #define INCLUDED_IMF_IMAGE_CHANNEL_RENAMING_H
8 
9 //----------------------------------------------------------------------------
10 //
11 // typedef RenamingMap,
12 // helper functions for image channel renaming.
13 //
14 //----------------------------------------------------------------------------
15 
16 #include "ImfNamespace.h"
17 #include <map>
18 #include <string>
19 
21 
22 //
23 // Given a map from old channel names to new channel names,
24 // rename the channels in an image or image level.
25 // This function assumes that the channel old-to-new-names
26 // map has already been checked for collisions.
27 //
28 
29 typedef std::map<std::string, std::string> RenamingMap;
30 
31 template <class ChannelMap>
32 inline void
34 {
35  ChannelMap renamedChannels;
36 
37  for (typename ChannelMap::const_iterator i = channels.begin ();
38  i != channels.end ();
39  ++i)
40  {
41  RenamingMap::const_iterator j = oldToNewNames.find (i->first);
42  std::string newName = (j == oldToNewNames.end ()) ? i->first
43  : j->second;
44  renamedChannels[newName] = i->second;
45  }
46 
47  channels = renamedChannels;
48 }
49 
51 
52 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER typedef std::map< std::string, std::string > RenamingMap
void renameChannelsInMap(const RenamingMap &oldToNewNames, ChannelMap &channels)
GLint j
Definition: glad.h:2733
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
std::unordered_map< char, int > ChannelMap
Definition: TypeDesc.h:16
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)