| 62 | |
| 63 | template<typename T> |
| 64 | ReturnType operator()( T *data ) |
| 65 | { |
| 66 | // \todo: remove this logic once `transformChannel` has been removed |
| 67 | int width = ( m_width == 0 ) ? data->readable().size() : m_width; |
| 68 | int height = ( m_height == 0 ) ? 1 : m_height; |
| 69 | |
| 70 | // present it as a single channel, single scanline image |
| 71 | OpenImageIOAlgo::DataView dataView( data ); |
| 72 | ImageSpec spec( width, height, 1, dataView.type.elementtype() ); |
| 73 | ImageBuf buffer( spec, data->baseWritable() ); |
| 74 | |
| 75 | ROI roi( |
| 76 | /* xbegin */ spec.x, /* xend */ spec.width, |
| 77 | /* ybegin */ spec.y, /* yend */ spec.height, |
| 78 | /* zbegin */ 0, /* zend */ 1, |
| 79 | /* chbegin */ 0, /* chend */ 1 |
| 80 | ); |
| 81 | |
| 82 | // convert in-place |
| 83 | #if OIIO_VERSION > 10800 |
| 84 | bool status = ImageBufAlgo::colorconvert( |
| 85 | /* dst */ buffer, /* src */ buffer, |
| 86 | /* from */ m_inputSpace, /* to */ m_outputSpace, |
| 87 | /* unpremult */ false, |
| 88 | /* context_key */ "", |
| 89 | /* context_value */ "", |
| 90 | /* colorconfig */ OpenImageIOAlgo::colorConfig(), |
| 91 | /* roi */ roi |
| 92 | ); |
| 93 | #elif OIIO_VERSION > 10701 |
| 94 | bool status = ImageBufAlgo::colorconvert( |
| 95 | /* dst */ buffer, /* src */ buffer, |
| 96 | /* from */ m_inputSpace, /* to */ m_outputSpace, |
| 97 | /* unpremult */ false, |
| 98 | /* colorconfig */ OpenImageIOAlgo::colorConfig(), |
| 99 | /* roi */ roi |
| 100 | ); |
| 101 | #else |
| 102 | bool status = ImageBufAlgo::colorconvert( |
| 103 | /* dst */ buffer, /* src */ buffer, |
| 104 | /* from */ m_inputSpace, /* to */ m_outputSpace, |
| 105 | /* unpremult */ false, |
| 106 | /* roi */ roi |
| 107 | ); |
| 108 | #endif |
| 109 | |
| 110 | if( !status ) |
| 111 | { |
| 112 | throw Exception( std::string( "ColorAlgo::transformImage : " + buffer.geterror() ) ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | const std::string &m_inputSpace; |
| 117 | const std::string &m_outputSpace; |
nothing calls this directly
no test coverage detected