Show
Ignore:
Timestamp:
11/05/08 16:04:38 (5 years ago)
Author:
robert
Message:

Added --replace-rgb-with-luminance option

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp

    r9095 r9103  
    15711571    MODULATE_ALPHA_BY_LUMINANCE, 
    15721572    MODULATE_ALPHA_BY_COLOUR, 
    1573     REPLACE_ALPHA_WITH_LUMINACE 
     1573    REPLACE_ALPHA_WITH_LUMINANACE, 
     1574    REPLACE_RGB_WITH_LUMINANCE 
    15741575}; 
    15751576 
     
    16101611}; 
    16111612 
    1612 void doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image, osg::Vec4& colour) 
     1613osg::Image* doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image, osg::Vec4& colour) 
    16131614{ 
    16141615    switch(op) 
    16151616    { 
    16161617        case (MODULATE_ALPHA_BY_LUMINANCE): 
     1618        { 
    16171619            std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl; 
    16181620            osgVolume::modifyImage(image,ModulateAlphaByLuminanceOperator());  
    1619             break; 
     1621            return image; 
     1622        } 
    16201623        case (MODULATE_ALPHA_BY_COLOUR): 
     1624        { 
    16211625            std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl; 
    16221626            osgVolume::modifyImage(image,ModulateAlphaByColourOperator(colour));  
    1623             break; 
    1624         case (REPLACE_ALPHA_WITH_LUMINACE): 
    1625             std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINACE"<<std::endl; 
     1627            return image; 
     1628        } 
     1629        case (REPLACE_ALPHA_WITH_LUMINANACE): 
     1630        { 
     1631            std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl; 
    16261632            osgVolume::modifyImage(image,ReplaceAlphaWithLuminanceOperator());  
    1627             break; 
     1633            return image; 
     1634        } 
     1635        case (REPLACE_RGB_WITH_LUMINANCE): 
     1636        { 
     1637            std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl; 
     1638            osg::Image* newImage = new osg::Image; 
     1639            newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType()); 
     1640            osgVolume::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(), 
     1641                                 newImage, 0, 0, 0, false); 
     1642            return newImage; 
     1643        } 
    16281644        default: 
    1629             break; 
     1645            return image; 
    16301646    } 
    16311647} 
     
    18991915    while(arguments.read("--modulate-alpha-by-luminance")) { colourSpaceOperation = MODULATE_ALPHA_BY_LUMINANCE; } 
    19001916    while(arguments.read("--modulate-alpha-by-colour", colourModulate.x(),colourModulate.y(),colourModulate.z(),colourModulate.w() )) { colourSpaceOperation = MODULATE_ALPHA_BY_COLOUR; } 
    1901     while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = REPLACE_ALPHA_WITH_LUMINACE; } 
     1917    while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = REPLACE_ALPHA_WITH_LUMINANACE; } 
     1918    while(arguments.read("--replace-rgb-with-luminance")) { colourSpaceOperation = REPLACE_RGB_WITH_LUMINANCE; } 
    19021919         
    19031920    bool resizeToPowerOfTwo = false; 
     
    21612178            ++itr) 
    21622179        {         
    2163             doColourSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
     2180            (*itr) = doColourSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
    21642181        } 
    21652182    }