Hi Donald,

Have you gone through your code with a debugger at all?  Check what
value of nHalfSrcHeight you are getting.

One fix to your code you could do would be to use /2 rather *0.5 as /2
can use integer maths, while *0.5 requires pImageSrc->t() to be
automatically promoted to a float for it work.

Robert.

On Wed, Apr 22, 2009 at 5:57 PM, Donald Cipperly <[email protected]> wrote:
> 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
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to