MCPcopy Create free account
hub / github.com/ImageEngine/cortex / readChannel

Method readChannel

src/IECoreImage/ImageReader.cpp:324–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322 }
323
324 DataPtr readChannel( const std::string &name, bool raw )
325 {
326 open( /* throwOnFailure */ true );
327
328 const ImageSpec *spec = m_cache->imagespec( m_inputFileName, /* subimage = */ 0, miplevel() );
329
330 const auto channelIt = find( spec->channelnames.begin(), spec->channelnames.end(), name );
331 if( channelIt == spec->channelnames.end() )
332 {
333 throw InvalidArgumentException( "Image Reader : Non-existent image channel \"" + name + "\" requested." );
334 }
335
336 size_t channelIndex = channelIt - spec->channelnames.begin();
337
338 if( raw )
339 {
340 switch( spec->format.basetype )
341 {
342 case TypeDesc::UCHAR :
343 {
344 return readTypedChannel<unsigned char>( channelIndex, spec->format );
345 }
346 case TypeDesc::CHAR :
347 {
348 return readTypedChannel<char>( channelIndex, spec->format );
349 }
350 case TypeDesc::USHORT :
351 {
352 return readTypedChannel<unsigned short>( channelIndex, spec->format );
353 }
354 case TypeDesc::SHORT :
355 {
356 return readTypedChannel<short>( channelIndex, spec->format );
357 }
358 case TypeDesc::UINT :
359 {
360 return readTypedChannel<unsigned int>( channelIndex, spec->format );
361 }
362 case TypeDesc::INT :
363 {
364 return readTypedChannel<int>( channelIndex, spec->format );
365 }
366 case TypeDesc::HALF :
367 {
368 return readTypedChannel<half>( channelIndex, spec->format );
369 }
370 case TypeDesc::FLOAT :
371 {
372 return readTypedChannel<float>( channelIndex, spec->format );
373 }
374 case TypeDesc::DOUBLE :
375 {
376 return readTypedChannel<double>( channelIndex, spec->format );
377 }
378 default :
379 {
380 throw IECore::IOException( ( boost::format( "ImageReader : Unsupported data type \"%d\"" ) % spec->format ).str() );
381 }

Callers

nothing calls this directly

Calls 5

findFunction · 0.85
InvalidArgumentExceptionFunction · 0.85
IOExceptionFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected