summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/image.cc10
-rw-r--r--plugingui/image.h3
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);