diff options
Diffstat (limited to 'src/DataImage.cxx')
-rw-r--r-- | src/DataImage.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/DataImage.cxx b/src/DataImage.cxx index 680d218..efc05e3 100644 --- a/src/DataImage.cxx +++ b/src/DataImage.cxx @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <math.h> #include <Fl/fl_draw.h> @@ -63,6 +64,23 @@ DataImage::draw() { } int +DataImage::get_pixel_bilinear(Fl_Image *img, double x, double y, + char *r, char *g, char *b) { + + +} + +int +DataImage::get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b) { + if (isnan(x) || isnan(y)) { + return 1; + } else { + return get_pixel(img, (int) rint(x), (int) rint(y), r, g, b); + } +} + +int DataImage::get_pixel(Fl_Image *img, int x, int y, char *r, char *g, char *b) { if ( img->d() == 0 ) { @@ -72,7 +90,6 @@ DataImage::get_pixel(Fl_Image *img, int x, int y, if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) { return 1; } - long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index switch ( img->count() ) { case 1: { // bitmap |