summaryrefslogtreecommitdiff
path: root/plugingui/image.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-30 16:19:20 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-30 16:19:20 +0100
commit360ec177c5f4573c01c0927d61fead7d1d5cbe34 (patch)
treefb3d9bb06f7edb6a581876f1cec44321c4ac336b /plugingui/image.cc
parenta09bbed0fc02bb61bf26d61398271e9b1f6283de (diff)
Added GUI::Colour getPixel convinience methods.
Diffstat (limited to 'plugingui/image.cc')
-rw-r--r--plugingui/image.cc10
1 files changed, 9 insertions, 1 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;
}