|
Boost Users : |
Subject: Re: [Boost-users] [GIL] How can I copy a subimage_view to a view?
From: blp330 (blp330_at_[hidden])
Date: 2009-04-27 13:36:34
Hi,
Thanks for your reply, I knew that.
Oh, let me clarify what problem I actually have:
Consider the class Image:
class Image
{
public:
Image()
{
}
Image(std::string& file)
{
// using io extension to read image.
// ...
}
Image(const Image& other)
{
img = other.img;
// view = boost::gil::view(img);
view = other.view;
}
Image& Image::Crop(int x, int y, int width, int height)
{
view = boost::gil::subimage_view(view, x, y, width, height);
return *this;
}
void Image::Crop(int x, int y, int width, int height, Image& out) const
{
out = *this;
out.Crop(x, y, width, height);
}
Image& Image::Fill(int x1, int y1, int x2, int y2,
int r, int g, int b)
{
boost::gil::rgb8_pixel_t pixel(r, g, b);
boost::gil::fill_pixels(
boost::gil::subimage_view(view, x1, y1, x2 - x1, y2 - y1), pixel);
return *this;
}
private:
boost::gil::rgb8_image_t img;
boost::gil::rgb8_image_t::view_t view;
};
Image a("a.png"); // 100x100 size.
a.Crop(100, 100, 50, 50); // Now, the a should be 50x50 size.
Image b;
a.Crop(0, 0, 10, 10, b); // b should be 10x10.
a.Fill(0, 0, 10, 10, 0xff, 0xff, 0xff); // This will cause b also filled
with white color.
How to change my Image class to make a.Fill not to affect b?
Thank you very much.
-- View this message in context: http://www.nabble.com/-GIL--How-can-I-copy-a-subimage_view-to-a-view--tp23234549p23261286.html Sent from the Boost - Users mailing list archive at Nabble.com.
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