Hi Robert,

I'm trying to copy the top half of an existing image using osg::copyImage.
I do this as such:

    // Read in source image
    osg::ref_ptr< osg::Image > pImageSrc = osgDB::readImageFile( "test.jpg"
);
    int nHalfSrcHeight = (int)(pImageSrc->t() * 0.5);

    // Allocate destination image
    osg::Image *pImageDest = new osg::Image();
    pImageDest->allocateImage(pImageSrc->s(), nHalfSrcHeight,
pImageSrc->r(), pImageSrc->getPixelFormat(), pImageSrc->getDataType());

    // Copy top half of source image to destination
    myCopyImage( pImageSrc.get(), 0, (nHalfSrcHeight-1), 0, pImageSrc->s(),
nHalfSrcHeight, pImageSrc->r(),
        pImageDest, 0, 0, 0, false );


This appears to be the correct way to perform this operation.  Is this
correct?  If so, then line 210 of osg/ImageUtils.cpp appears to be incorrect
as it notifies that my input height is too large.  And indeed when I commend
out the block below in ImageUtils.cpp, then it outputs the top half of my
image as I expect.

    if ((src_t+height) > (dest_t + destImage->t()))
    {
        osg::notify(osg::NOTICE)<<"copyImage("<<srcImage<<", "<<src_s<<",
"<< src_t<<", "<<src_r<<", "<<width<<", "<<height<<", "<<depth<<std::endl;
        osg::notify(osg::NOTICE)<<"          "<<destImage<<", "<<dest_s<<",
"<< dest_t<<", "<<dest_r<<", "<<doRescale<<")"<<std::endl;
        osg::notify(osg::NOTICE)<<"   input height too large."<<std::endl;
        return false;
    }

Thanks for any help you can provide,

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

Reply via email to