| 422 | } |
| 423 | |
| 424 | Image Image::subImage(Vec2U const& pos, Vec2U const& size) const { |
| 425 | if (pos[0] + size[0] > m_width || pos[1] + size[1] > m_height) |
| 426 | throw ImageException(strf("call to subImage with pos {} size {} out of image bounds ({}, {})", pos, size, m_width, m_height)); |
| 427 | |
| 428 | Image sub(size[0], size[1], m_pixelFormat); |
| 429 | |
| 430 | for (unsigned y = 0; y < size[1]; ++y) { |
| 431 | for (unsigned x = 0; x < size[0]; ++x) { |
| 432 | sub.set({x, y}, get(pos + Vec2U(x, y))); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | return sub; |
| 437 | } |
| 438 | |
| 439 | void Image::copyInto(Vec2U const& min, Image const& image) { |
| 440 | Vec2U max = (min + image.size()).piecewiseMin(size()); |