Hi,

this small test app still works fine on my side for RGB and GRAY images... Does it work for you?

I'm not sure what's happening on your side. Maybe try without manually setting pixel format.

jp

On 29/04/10 11:23, Vedran Pavlic wrote:
Hi,

Ok, I looked into it some more and it doesn't work even for .bmp extensions, 
the image gets scrambled. Is there a way to convert osg::Image to some other 
image type, preferably CLR System::Drawing::Image or one of boost types. My 
first idea was to write osg::Image to a stream and read that to the other type, 
but since this is failing I decided to ask like this.

Thank you!

Cheers,
Vedran

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=27428#27428





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.

/* OpenSceneGraph example, osgcompositeviewer.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

#include <iostream>
#include <sstream>

#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>


#include <osg/Material>
#include <osg/Geode>
#include <osg/BlendFunc>
#include <osg/Depth>
#include <osg/Projection>
#include <osg/PolygonOffset>
#include <osg/MatrixTransform>
#include <osg/Camera>
#include <osg/FrontFace>

#include <osgText/Text>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/StateSetManipulator>
#include <osgViewer/ViewerEventHandlers>

#include <osgViewer/CompositeViewer>

#include <osgFX/Scribe>

#include <osg/io_utils>

#include <osgDB/FileUtils>
#include <osgDB/ReadFile>

int main( int argc, char **argv )
{
    osg::ref_ptr<osg::Image> startIm = osgDB::readImageFile("test.jpg");

    //osgDB::writeImageFile(*startIm, "new.png");
    //osgDB::writeImageFile(*startIm, "new.jpg");

    osg::ref_ptr<osgDB::ReaderWriter> writer = 
        //osgDB::Registry::instance()->getReaderWriterForExtension("jpg");
        osgDB::Registry::instance()->getReaderWriterForExtension("png");

    if( !writer.valid() )
        return -1;

    osg::ref_ptr<osgDB::ReaderWriter::Options> op = new osgDB::ReaderWriter::Options();
    //op->setOptionString("JPEG_QUALITY 75");
    op->setOptionString("PNG_COMPRESSION 9");

    for(int i=0;i<1;i++) {
        std::stringstream ss;
        osgDB::ReaderWriter::WriteResult res = writer->writeImage(*startIm,ss,op);
        std::cout << ss.str().size() << "\n";

        std::ofstream fout("test.png");
        fout << ss.str();
    }
    return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to