| 1 | // Aseprite Document Library |
| 2 | // Copyright (c) 2001-2015 David Capello |
| 3 | // |
| 4 | // This file is released under the terms of the MIT license. |
| 5 | // Read LICENSE.txt for more information. |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
| 11 | #include "doc/image_impl.h" |
| 12 | |
| 13 | #include "doc/image_iterator.h" |
| 14 | #include "doc/image_traits.h" |
| 15 | |
| 16 | namespace doc { |
| 17 | |
| 18 | void copy_bitmaps(Image* dst, const Image* src, gfx::Clip area) |
| 19 | { |
| 20 | if (!area.clip(dst->width(), dst->height(), src->width(), src->height())) |
| 21 | return; |
| 22 | |
| 23 | // Copy process |
| 24 | ImageConstIterator<BitmapTraits> src_it(src, area.srcBounds(), area.src.x, area.src.y); |
| 25 | ImageIterator<BitmapTraits> dst_it(dst, area.dstBounds(), area.dst.x, area.dst.y); |
| 26 | |
| 27 | int end_x = area.dst.x+area.size.w; |
| 28 | |
| 29 | for (int end_y=area.dst.y+area.size.h; |
| 30 | area.dst.y<end_y; |
| 31 | ++area.dst.y, ++area.src.y) { |
| 32 | for (int x=area.dst.x; x<end_x; ++x) { |
| 33 | *dst_it = *src_it; |
| 34 | ++src_it; |
| 35 | ++dst_it; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | } // namespace doc |
| 41 | |