| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2001-2015 David Capello |
| 3 | // |
| 4 | // This program is distributed under the terms of |
| 5 | // the End-User License Agreement for Aseprite. |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
| 11 | #include "app/cmd/flip_image.h" |
| 12 | |
| 13 | #include "doc/image.h" |
| 14 | #include "doc/algorithm/flip_image.h" |
| 15 | |
| 16 | namespace app { |
| 17 | namespace cmd { |
| 18 | |
| 19 | FlipImage::FlipImage(Image* image, const gfx::Rect& bounds, doc::algorithm::FlipType flipType) |
| 20 | : WithImage(image) |
| 21 | , m_bounds(bounds) |
| 22 | , m_flipType(flipType) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | void FlipImage::onExecute() |
| 27 | { |
| 28 | swap(); |
| 29 | } |
| 30 | |
| 31 | void FlipImage::onUndo() |
| 32 | { |
| 33 | swap(); |
| 34 | } |
| 35 | |
| 36 | void FlipImage::swap() |
| 37 | { |
| 38 | Image* image = this->image(); |
| 39 | |
| 40 | // Flip the portion of the bitmap. |
| 41 | doc::algorithm::flip_image(image, m_bounds, m_flipType); |
| 42 | |
| 43 | image->incrementVersion(); |
| 44 | } |
| 45 | |
| 46 | } // namespace cmd |
| 47 | } // namespace app |
| 48 |