diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-06 09:30:52 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-06 09:30:52 +0100 |
commit | a0b7282b31ed31051ee98bf16e8704d5599e5461 (patch) | |
tree | 49798ac70adbac0e065781833f045bab8a65bb0b /plugingui/pixelbuffer.cc | |
parent | dff2ff5b636d9d7007bf8589204e6a7138ee4004 (diff) |
Major GUI workover. Hilights: A new filebrowser and new knob widget.
Diffstat (limited to 'plugingui/pixelbuffer.cc')
-rw-r--r-- | plugingui/pixelbuffer.cc | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/plugingui/pixelbuffer.cc b/plugingui/pixelbuffer.cc index fb4d05f..e9e376a 100644 --- a/plugingui/pixelbuffer.cc +++ b/plugingui/pixelbuffer.cc @@ -62,7 +62,7 @@ GUI::PixelBufferAlpha::PixelBufferAlpha(size_t width, size_t height) { this->idx = ::idx++; buf = NULL; - x = y = 0; + x = y = 10; realloc(width, height); } @@ -84,12 +84,39 @@ void GUI::PixelBufferAlpha::setPixel(size_t x, size_t y, { // printf("%d %d %d %d\n", red, green, blue, alpha); if(x >= width || y >= height) return; + /* + float a = alpha / 255.0; + buf[PX(0)] = (unsigned char)(red * a + buf[PX(0)] * (1-a)); + buf[PX(1)] = (unsigned char)(green * a + buf[PX(1)] * (1-a)); + buf[PX(2)] = (unsigned char)(blue * a + buf[PX(2)] * (1-a)); + buf[PX(3)] = (unsigned char)(alpha * a + buf[PX(3)] * (1-a)); + */ buf[PX(0)] = red; buf[PX(1)] = green; buf[PX(2)] = blue; buf[PX(3)] = alpha; } +void GUI::PixelBufferAlpha::addPixel(size_t x, size_t y, + unsigned char red, + unsigned char green, + unsigned char blue, + unsigned char alpha) +{ + // printf("%d %d %d %d\n", red, green, blue, alpha); + if(x >= width || y >= height) return; + + if(alpha == 0) return; + + float a = (float)alpha / (float)(alpha + buf[PX(3)]); + buf[PX(0)] = (unsigned char)(red * a + buf[PX(0)] * (1-a)); + buf[PX(1)] = (unsigned char)(green * a + buf[PX(1)] * (1-a)); + buf[PX(2)] = (unsigned char)(blue * a + buf[PX(2)] * (1-a)); + + //buf[PX(3)] = (unsigned char)(alpha * a + buf[PX(3)] * (1-a)); + buf[PX(3)] = alpha>buf[PX(3)]?alpha:buf[PX(3)]; +} + void GUI::PixelBufferAlpha::pixel(size_t x, size_t y, unsigned char *red, unsigned char *green, |