01/24/12 15:34:02 (6 years ago)

Added support for using GL_UNPACK_ROW_LENGTH in conjunction with texture's + osg::Image via new RowLength?
parameter in osg::Image. To support this Image::setData(..) now has a new optional rowLength parameter which
defaults to 0, which provides the original behaviour, Image::setRowLength(int) and int Image::getRowLength() are also provided.

With the introduction of RowLength? support in osg::Image it is now possible to create a sub image where
the t size of the image are smaller than the row length, useful for when you have a large image on the CPU
and which to use a small portion of it on the GPU. However, when these sub images are created the data
within the image is no longer contiguous so data access can no longer assume that all the data is in
one block. The new method Image::isDataContiguous() enables the user to check whether the data is contiguous,
and if not one can either access the data row by row using Image::data(column,row,image) accessor, or use the
new Image::DataIterator? for stepping through each block on memory assocatied with the image.

To support the possibility of non contiguous osg::Image usage of image objects has had to be updated to
check DataContiguous? and handle the case or use access via the DataIerator? or by row by row. To achieve
this a relatively large number of files has had to be modified, in particular the texture classes and
image plugins that doing writing.

1 modified


  • OpenSceneGraph/trunk/src/osgPlugins/imageio/ReaderWriterImageIO.cpp

    r12789 r12912  
    12001200    WriteResult writeImageStream(const osg::Image& osg_image, std::ostream& fout, const osgDB::ReaderWriter::Options* the_options) const 
    12011201    { 
     1202        if (!osg_image.isDataContiguous()) 
     1203        { 
     1204            return WriteResult::FILE_NOT_HANDLED; 
     1205        } 
    12021207        WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12361241    WriteResult writeImageFile(const osg::Image& osg_image, const std::string& full_file_name, const osgDB::ReaderWriter::Options* the_options) const 
    12371242    { 
     1243        if (!osg_image.isDataContiguous()) 
     1244        { 
     1245            return WriteResult::FILE_NOT_HANDLED; 
     1246        } 
     1248        WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12381249        WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12391250        // Call ImageIO to load the image. 
    12691280        if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED; 
     1282        if (!osg_image.isDataContiguous()) 
     1283        { 
     1284            return WriteResult::FILE_NOT_HANDLED; 
     1285        } 
     1287        WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12711288#if 1 
    12721289        // FIXME: Something may need to provide a proper writable location for the files.