|
Boost Users : |
Subject: Re: [Boost-users] [GIL] How can I copy a subimage_view to a view?
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-04-26 12:29:59
Hi there, you're passing an Image into your and override the view
member with a view to the a local gil::image. After the crop function
is done this local image is destroyed the the view to that image now
points to garbage.
Also it's unclear to me how you initialize the view member in your Image class.
This works on my machine:
#include <boost/gil/gil_all.hpp>
using namespace boost::gil;
rgb8_image_t s( 100, 100 );
class Image
{
public:
Image( rgb8_view_t v )
: _view( v )
{}
void crop( int x, int y, int width, int height, Image& out )
{
copy_pixels( subimage_view( _view
, 0
, 0
, 100
, 100
)
, view( s )
);
out._view = view( s );
}
public:
rgb8_view_t _view;
};
int main ( int argc , char **argv)
{
rgb8_image_t img( 100, 100 );
Image i( view( img ) );
Image out( view( img ) );
i.crop( 100, 100, 50, 50, out );
return 0;
}
Cheers,
Christian
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net