Show
Ignore:
Timestamp:
02/01/05 10:02:01 (10 years ago)
Author:
robert
Message:

Added code for rescaling images.

Files:
1 modified

Legend:

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

    r3798 r3801  
    873873}; 
    874874 
     875struct RecordRowOperator 
     876{ 
     877    RecordRowOperator(unsigned int num):_colours(num),_pos(0) {} 
     878 
     879    mutable std::vector<osg::Vec4>  _colours; 
     880    mutable unsigned int            _pos; 
     881     
     882    inline void luminance(float l) const { rgba(l,l,l,1.0f); }  
     883    inline void alpha(float a) const { rgba(1.0f,1.0f,1.0f,a); }  
     884    inline void luminance_alpha(float l,float a) const { rgba(l,l,l,a);  }  
     885    inline void rgb(float r,float g,float b) const { rgba(r,g,b,1.0f); } 
     886    inline void rgba(float r,float g,float b,float a) const { _colours[_pos++].set(r,g,b,a); } 
     887}; 
     888 
     889struct WriteRowOperator 
     890{ 
     891    WriteRowOperator():_pos(0) {} 
     892    WriteRowOperator(unsigned int num):_colours(num),_pos(0) {} 
     893 
     894    std::vector<osg::Vec4>  _colours; 
     895    mutable unsigned int    _pos; 
     896     
     897    inline void luminance(float& l) const { l = _colours[_pos++].red(); }  
     898    inline void alpha(float& a) const { a = _colours[_pos++].alpha(); }  
     899    inline void luminance_alpha(float& l,float& a) const { l = _colours[_pos].red(); a = _colours[_pos++].alpha(); }  
     900    inline void rgb(float& r,float& g,float& b) const { r = _colours[_pos].red(); g = _colours[_pos].green(); b = _colours[_pos].blue(); } 
     901    inline void rgba(float& r,float& g,float& b,float& a) const {  r = _colours[_pos].red(); g = _colours[_pos].green(); b = _colours[_pos].blue(); a = _colours[_pos++].alpha(); } 
     902}; 
     903 
    875904osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent, int numberOfComponents, const std::string& endian, const std::string& raw_filename) 
    876905{ 
     
    969998 
    970999    fin.close(); 
     1000 
     1001    if (dataType!=GL_UNSIGNED_BYTE) 
     1002    { 
     1003        // need to convert to ubyte 
     1004    } 
    9711005     
    9721006    return image.release(); 
     
    9741008     
    9751009} 
     1010 
    9761011 
    9771012int main( int argc, char **argv )