summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAlexander Holland <alexander.holland@live.de>2018-04-29 15:17:06 +0200
committerAlexander Holland <alexander.holland@live.de>2018-04-29 15:17:06 +0200
commit97485c8df03af04e8459f3ca72c3d60f6985daa1 (patch)
treea22e774f204045a3fb8add498b7735eaed1c37de /core
parentd0183effe02edb973e44e5ad8b3608d861f86490 (diff)
add Point2 helper for Image.get_pixel and Image.set_pixel
image-point2-helper
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp12
-rw-r--r--core/image.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 2ac8ffea56..e143623c73 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1880,6 +1880,10 @@ void Image::unlock() {
write_lock = PoolVector<uint8_t>::Write();
}
+Color Image::get_pixelv(const Point2 &p_src) const {
+ return get_pixel(p_src.x, p_src.y);
+}
+
Color Image::get_pixel(int p_x, int p_y) const {
uint8_t *ptr = write_lock.ptr();
@@ -2026,6 +2030,10 @@ Color Image::get_pixel(int p_x, int p_y) const {
return Color();
}
+void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
+ return set_pixel(p_dst.x, p_dst.y, p_color);
+}
+
void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
uint8_t *ptr = write_lock.ptr();
@@ -2257,8 +2265,10 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("lock"), &Image::lock);
ClassDB::bind_method(D_METHOD("unlock"), &Image::unlock);
- ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel);
+ ClassDB::bind_method(D_METHOD("get_pixelv", "src"), &Image::get_pixelv);
ClassDB::bind_method(D_METHOD("get_pixel", "x", "y"), &Image::get_pixel);
+ ClassDB::bind_method(D_METHOD("set_pixelv", "dst", "color"), &Image::set_pixelv);
+ ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel);
ClassDB::bind_method(D_METHOD("load_png_from_buffer", "buffer"), &Image::load_png_from_buffer);
ClassDB::bind_method(D_METHOD("load_jpg_from_buffer", "buffer"), &Image::load_jpg_from_buffer);
diff --git a/core/image.h b/core/image.h
index 17477d88ea..d6cdd8591e 100644
--- a/core/image.h
+++ b/core/image.h
@@ -321,7 +321,9 @@ public:
DetectChannels get_detected_channels();
+ Color get_pixelv(const Point2 &p_src) const;
Color get_pixel(int p_x, int p_y) const;
+ void set_pixelv(const Point2 &p_dest, const Color &p_color);
void set_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) {