I have an image with multiple colours present (lets call it the mask). I also have a list of 'selected' colours. My renderscript makes a new image that I use as an overlay. If a colour is present in both the mask and the selected list, the overlay should be red in that area, else green.
Note that the resulting image, with the red mask over it, has a green line in between. I have ensured that anti-aliasing is off when I create the first image, so that there are no unexpected colours in the 'mask'. But, for some reason, it is not seen as the one or the other colour in my renderscript. Here is the code:
#pragma version(1)
#pragma rs java_package_name(za.co.overtake)
int*reds;
int*greens;
int*blues;
int imgWidth;
uchar4 RS_KERNEL root(uchar4 in, uint32_t x, uint32_t y) {
bool colourme = false;
for(int col = 0; col < imgWidth; col++){
const int red = reds[col];
const int green = greens[col];
const int blue = blues[col];
if (in.r == red && in.g == green && in.b == blue){
colourme = true;
}
}
if (colourme) {
in.r = 117;
in.g = 0;
in.b = 0;
in.a = 100;
} else if (in.a > 200) {
in.r = 10;
in.g = 60;
in.b = 10;
in.a = 100;
} else {
in.r = 0;
in.g = 0;
in.b = 0;
in.a = 0;
}
return in;
}
Any help will be appreciated. I'm still new at this and I've been stuck forever!