forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_sprite_pixel.cpp
More file actions
35 lines (25 loc) · 772 Bytes
/
get_sprite_pixel.cpp
File metadata and controls
35 lines (25 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Aseprite Render Library
// Copyright (c) 2001-2014 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "doc/doc.h"
#include "gfx/clip.h"
#include "render/render.h"
namespace render {
using namespace doc;
color_t get_sprite_pixel(const Sprite* sprite, int x, int y, frame_t frame)
{
color_t color = 0;
if ((x >= 0) && (y >= 0) && (x < sprite->width()) && (y < sprite->height())) {
base::UniquePtr<Image> image(Image::create(sprite->pixelFormat(), 1, 1));
render::Render().renderSprite(image, sprite, frame,
gfx::Clip(0, 0, x, y, 1, 1));
color = get_pixel(image, 0, 0);
}
return color;
}
} // namespace render