%ffp Category: "Adjustment" Title: "Hue/Saturation" Filename: "adjustment.8bf" Copyright:"© 2007 GPL" Author: "Alois Zingl" Version: "1.0" URL: "http://free.pages.at/easyfilter/filtermeister.html" Description:"Adjustment of hue, saturation, lightness and contrast." SupportedModes: RGBMode, RGB48Mode ctl(0): "Hue", range=(-180,180) ctl(1): "Saturation", range=(-100,100) ctl(2): "Lightness", range=(-100,100) ctl(3): "Contrast", range=(-100,100) // ForEveryPixel can't handle 16Bit mode -> must use ForEveryTile OnFilterStart: { isTileable = true; needPadding = 0; return false; } ForEveryTile: { const int M = imageMode min,median,max if (get(mi)>get(ma)) {i=mi; mi=ma; ma=i; h=-h;} if (get(mi)>get(mm)) {i=mi; mi=mm; mm=i; h=-h;} if (get(mm)>get(ma)) {i=mm; mm=ma; ma=i; h=-h;} mx = get(ma); mn = get(mi); i=get(mm)-h*(mx-mn)/60; // shift median color if (i>mx) // if clipping occurs { put(mx,mm); // shift max color ... put(mx+(mx-i),ma); } else if (i>1; // grey if (s>0) // check saturation clipping (to avoid hue change) { if (l>0) // lightness may reduce clipping mn = M-(M-mn)*(100-l)/100; else mx = mx*(100+l)/100; s = min(s,(M-mx)*100/(M-g)); // max clipping s = max(0,min(s,mn*100/g)); // min clipping } for (z=0; z<3; z++) if (s>0) put(mix1(get(z),g,100,100-s),z); else put(mix1(get(z),g,100+s,100),z); // contrast for (z=0; z<3; z++) if (c>0) put(scl(get(z),c,M-c,0,M),z); else put(scl(get(z),0,M,-c,M+c),z); // lightness for (z=0; z<3; z++) if (l>0) pset(x,y,z,M-(M-get(z))*(100-l)/100); else pset(x,y,z,get(z)*(100+l)/100); } } return true; }