Thanks for the help. vil_stream_core cannot be used without deriving it (it has a protected destructor). I've created a simple derived class and I end up with the same problem when using it.
I'll try that debugging tip with vil_stream_core.
R & D Engineer
Not that this will fix your actual problem, but you are trying to write into a buffer, so why go via a vil_stream_fstream which wraps a real file? Just use the in memory derivative of vil_stream - vil_stream_core.
Have you checked if your tmp file contains a valid png?
One possibility is that the png image resource won't finish (or possibly even start) writing the file until the resource is destroyed.
If it isn't that, I can't see anything obviously wrong. But I start debugging by putting a break point at the vil_stream_whatever::write() method and check that meaningful data is going into the stream.
Patrick Reynolds wrote:
Hi all,frame.ni <http://frame.ni>(),
I'm trying to write a simple application that takes a vil_image_view and writes it to a buffer in a given encoding, png for example. The method in which I'm trying to do this seems logical, but doesn't yield the correct data into the buffer (code below):
vil_image_view<vxl_byte> frame = vil_load( "test.png" );
vil_stream_fstream* pngStream = new vil_stream_fstream( "tmp", "r" ); // I've tried this with 'w' as well
vil_image_resource_sptr pngImageRes = png.make_output_image(
pngImageRes->put_view( frame );
char* buf = new char[ pngStream->file_size() ];
pngStream->read( buf, pngStream->file_size() );
I've also tried this using a simple sub-class of vil_stream_core that simply makes its destructor public, but I get the same or similar results. Hopefully, I'm missing something simple.
Also, sorry if this is a question that's been asked before, sourceforge's mailing list search seems to be broken... Anyone know of another way to search it?
R & D Engineer