@PropertyMax(255)
private int luminosity = 0;
@Override
protected void performPixelTransformation(WFImage pImg) {
SimpleImage img = (SimpleImage) pImg;
int width = pImg.getImageWidth();
int height = pImg.getImageHeight();
Pixel rgbPixel = new Pixel();
HSLPixel hslPixel = new HSLPixel();
double phue = (double) (this.hue) / 255.0;
if (phue < (-1.0))
phue = -1;
else if (phue > 1.0)
phue = 1.0;
double psaturation = (double) (this.saturation) / 255.0;
if (psaturation < (-1.0))
psaturation = -1.0;
else if (psaturation > 1.0)
psaturation = 1.0;
double pluminosity = (double) (this.luminosity) / 255.0;
if (pluminosity < (-1.0))
pluminosity = -1;
else if (pluminosity > 1.0)
pluminosity = 1.0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
rgbPixel.setARGBValue(img.getARGBValue(j, i));
rgb2hsl(rgbPixel, hslPixel);
hslPixel.luminosity += pluminosity;
if (hslPixel.luminosity < 0.0)
hslPixel.luminosity = 0.0;
else if (hslPixel.luminosity > 1.0)
hslPixel.luminosity = 1.0;
hslPixel.saturation += psaturation;
if (hslPixel.saturation < 0.0)
hslPixel.saturation = 0.0;
else if (hslPixel.saturation > 1.0)
hslPixel.saturation = 1.0;
if (hslPixel.hue != (-1.0)) {
hslPixel.hue += phue;
if (hslPixel.hue < 0.0)
hslPixel.hue += 1.0;
else if (hslPixel.hue > 1.0)
hslPixel.hue -= 1.0;
}
hsl2rgb(hslPixel, rgbPixel);
img.setRGB(j, i, rgbPixel);
}
}
}