subtype idKGScriptParserduration?ð framebaseencodingparms inputFormat inputCountpublicspudtitlewww.fxscript.orguitype typedefaultstringvaluechannelChanneluiinfolabelsRGBAlphaRedGreenBluemin?€max@ ?€?€ blackpoint black input"À#C whitepoint  white output"#EÀC€C€rampB¸snapdetentsC€gammaGamma"<#× #@€?€?€graphondraw graph of curve on image"#privatestaticsscript}//a level & gamma control //©2002 Stephen dixon //this software is free. You may copy and distribute i as long as this message is included //see www.fxscript.org for more filter "simple Levels"; group "stib's filters"; input spud, "www.fxscript.org", Label, "string" input Channel, "Channel", popup, 1, "RGB", "Alpha", "Red", "Green", "Blue"; input blackpoint, "black input", slider, 0, -256, 255 ; input whitepoint, "white output", slider, 256, 0, 2300 ramp 92 detent 256; input gamma, "Gamma", slider, 1, 0.01, 4 ; input GraphOn, "draw graph of curve on image", CheckBox, false code float i, clut[256], gain, Xoffset, screenwidth, screenheight ; point graphPoint , xaxis, yaxis ; gain = whitepoint/(256 - blackpoint); Xoffset = -1/256*(blackpoint * gain); //make our offset scale -1 to +1 for i = 0 to 255 clut[i] = gain * power(i/256, gamma)+ Xoffset ; if clut[i]>1 clut [i] = 1; else if clut[i]< 0 clut[i]= 0; end if; next; if Channel == 5 // blue levelMap(Src1, Dest, LinearRamp, LinearRamp, LinearRamp, clut); else if Channel == 4 // green levelMap(Src1, Dest, LinearRamp, LinearRamp, clut, LinearRamp); else if Channel == 3 // red levelMap(Src1, Dest, LinearRamp, clut, LinearRamp, LinearRamp); else if Channel == 2 // alpha levelMap(Src1, Dest, clut, LinearRamp, LinearRamp, LinearRamp); else // all levelMap(Src1, Dest, LinearRamp, clut, clut, clut); end if; if GraphOn { for i = 0 to 255 DimensionsOf(dest, screenwidth, screenheight); screenheight *= 0.8; screenwidth *= 0.8; graphPoint = {i/256*screenwidth - screenwidth/2,(screenheight/2)-clut[i]*screenheight}; xaxis = {i/256*screenwidth - screenwidth/2,screenheight/2} yaxis = {screenwidth/2,(screenheight/2)-i/256*screenheight} DrawSoftDot(Dest, xaxis , kRound, 2, 5, 1, kRed, 50, 1); DrawSoftDot(Dest, yaxis , kRound, 2, 5, 1, kRed, 50, 1) DrawSoftDot(Dest, graphPoint, kRound, 3, 5, 1, kWhite, 100, 1) next; end if; name simple Levelsscriptid<groupstib's filtersencoded