diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-30 16:19:20 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-30 16:19:20 +0100 |
commit | 360ec177c5f4573c01c0927d61fead7d1d5cbe34 (patch) | |
tree | fb3d9bb06f7edb6a581876f1cec44321c4ac336b | |
parent | a09bbed0fc02bb61bf26d61398271e9b1f6283de (diff) |
Added GUI::Colour getPixel convinience methods.
-rw-r--r-- | plugingui/image.cc | 10 | ||||
-rw-r--r-- | plugingui/image.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/plugingui/image.cc b/plugingui/image.cc index 4864007..e4f7391 100644 --- a/plugingui/image.cc +++ b/plugingui/image.cc @@ -148,8 +148,16 @@ size_t GUI::Image::height() GUI::Colour GUI::Image::getPixel(size_t x, size_t y) { + if(x > width() || y > height()) return GUI::Colour(0,0,0,0); png_byte* row = row_pointers[y]; png_byte* ptr = &(row[x*4]); - GUI::Colour c(ptr[0], ptr[1], ptr[2], ptr[3]); + float r = ptr[0]; + float g = ptr[1]; + float b = ptr[2]; + float a = ptr[3]; + GUI::Colour c(r / 255.0, + g / 255.0, + b / 255.0, + a / 255.0); return c; } diff --git a/plugingui/image.h b/plugingui/image.h index f931d43..1df248f 100644 --- a/plugingui/image.h +++ b/plugingui/image.h @@ -46,9 +46,6 @@ public: Colour getPixel(size_t x, size_t y); - unsigned int *pixels; - unsigned int order; - private: void load(const char* data, size_t size); |