Hi Oliver,

I'm currently review your submission and have created a small example
as per your suggestion that reproduces the bug with svn/trunk.  I have
also applied your fix and confirmed that it solves the bug.

However, I reluctant to merge the fix as it's really rather over
complicated and difficult to follow, it takes some quite straight
forward code that it quite easy to follow to one that far less
readable, and with it will also be less maintainable going forward.
The fix feels very much like a hacky workaround to a pecularity/bug
else where.

Could you explain how you can about this fix.  From reading it looks
like libtiff is generating seeks over the end of stream that causes
problems for a stringstream but not a ofstream.   I am hopeful that we
can come up with a far cleaner fix that what you've posted so far, so
I want to get to the bottom of the issue.

Thanks,
Robert.

On Tue, Apr 19, 2011 at 11:47 AM, Oliver Neumann <[email protected]> wrote:
> Hi,
>
> I posted a solution for the ReaderWriterTIFF plugin awhile ago for 
> discussion. Here is my final proposal for fixing this bug. For a simple 
> reconstruction of the bug try this short code:
>
>
> Code:
>
> osg::Image* img = new osg::Image();
> img->allocateImage(32,32,1,GL_RGB, GL_UNSIGNED_BYTE);
> osgDB::ReaderWriter* _rw = 
> osgDB::Registry::instance()->getReaderWriterForExtension("tiff");
> osgDB::ReaderWriter::Options* _rwOptions = new osgDB::ReaderWriter::Options();
>
> std::stringstream outStream;
> std::ofstream outfile("outp.tif", std::ios::out | std::ios::binary);
>
> _rw->writeImage( *img, outfile, _rwOptions); //Line A
> /*_rw->writeImage( *img, outStream, _rwOptions); //Line B
> std::string outBuf = outStream.str();
> outfile << outBuf;
> */
> outfile.close();
>
>
>
>
> The variation with the ofstream (Line A) works with the current 
> implementation, the variation with the stringstream (Line B) will result in 
> error messages and corrupt Tiffs. When using the attached fixed 
> implementation, both versions work.
> This functionallity is needed to allow osgEarth the caching of depth maps 
> into sqlite databases.
>
> Greetings,
> Oliver
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38580#38580
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/readerwritertiff_202.cpp
>
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to