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 <string>
18 #include <map>
19 
21 
22 
23 //
24 // Given a map from old channel names to new channel names,
25 // rename the channels in an image or image level.
26 // This function assumes that the channel old-to-new-names
27 // map has already been checked for collisions.
28 //
29 
30 typedef std::map <std::string, std::string> RenamingMap;
31 
32 template <class ChannelMap>
33 inline void
35 {
36  ChannelMap renamedChannels;
37 
38  for (typename ChannelMap::const_iterator i = channels.begin();
39  i != channels.end();
40  ++i)
41  {
42  RenamingMap::const_iterator j = oldToNewNames.find (i->first);
43  std::string newName = (j == oldToNewNames.end())? i->first: j->second;
44  renamedChannels[newName] = i->second;
45  }
46 
47  channels = renamedChannels;
48 }
49 
50 
51 
53 
54 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:80
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:79
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)