1 | // Aseprite Render Library |
2 | // Copyright (c) 2019 Igara Studio S.A. |
3 | // Copyright (c) 2001-2018 David Capello |
4 | // |
5 | // This file is released under the terms of the MIT license. |
6 | // Read LICENSE.txt for more information. |
7 | |
8 | #ifdef HAVE_CONFIG_H |
9 | #include "config.h" |
10 | #endif |
11 | |
12 | #include "doc/doc.h" |
13 | #include "gfx/clip.h" |
14 | #include "render/render.h" |
15 | |
16 | namespace render { |
17 | |
18 | using namespace doc; |
19 | |
20 | color_t get_sprite_pixel(const Sprite* sprite, |
21 | const double x, |
22 | const double y, |
23 | const frame_t frame, |
24 | const Projection& proj, |
25 | const bool newBlend) |
26 | { |
27 | color_t color = 0; |
28 | |
29 | if ((x >= 0.0) && (x < sprite->width()) && |
30 | (y >= 0.0) && (y < sprite->height())) { |
31 | std::unique_ptr<Image> image(Image::create(sprite->pixelFormat(), 1, 1)); |
32 | |
33 | render::Render render; |
34 | render.setNewBlend(newBlend); |
35 | render.setRefLayersVisiblity(true); |
36 | render.setProjection(proj); |
37 | render.renderSprite( |
38 | image.get(), sprite, frame, |
39 | gfx::ClipF(0, 0, proj.applyX(x), proj.applyY(y), 1, 1)); |
40 | |
41 | color = get_pixel(image.get(), 0, 0); |
42 | } |
43 | |
44 | return color; |
45 | } |
46 | |
47 | } // namespace render |
48 | |