Forum: Multimedia
Delphi
by Medium,
25. Jan 2010
Mh, then there is no obvious reason for this darkening. You could use your reference output and compare a white-tinted image (= implicit conversion to grayscales) of just a pure red, green and blue area to derive the weights they used, to make your output similar to it. That is, if you approve of the reference :)
Forum: Multimedia
Delphi
by Medium,
23. Jan 2010
As I already said, change the line
tmp := t*a + (1-t)*b;
to
tmp := (1-t)*a + t*b;
Another thing is, that it's not clear to me, which variable holds the original color. Color or Row? If it's Row, then change
Row.R := Lerp(Color.R, (Color.R * Row.R) div 255, APercent / 100);
to
Row.R := Lerp(Row.R, (Color.R * Row.R) div 255, APercent / 100);
Forum: Multimedia
Delphi
by Medium,
22. Jan 2010
If this is not what you get after the change, please post the whole part of your source. Otherwise we won't come far here. I won't ask for it a third time, since the code you provided had little to do with the Lerp() function, and as such can't relate to the problem. (It should work as well if you handled each channel separately, as already said.)
Forum: Multimedia
Delphi
by Medium,
22. Jan 2010
:gruebel: Lerp() can be used for just this. Use the original color of a pixel as first parameter, and the color of that pixel as if the effect was applied fully as second. Pass any value between 0 and 1 as third parameter, and get a linear interpolation between the original and the fully affected color. What exactly is your problem? You might also want to provide some more of your actual code...
Forum: Multimedia
Delphi
by Medium,
22. Jan 2010
I haven't really understood what you do with this particular filter, but it looks like you're looking for simple linear interpolation, where you can shift beween two values freely.
function Lerp(a, b: Byte; t: Double): Byte;
var
tmp: Double;
begin
tmp := t*a + (1-t)*b;
if tmp<0 then result := 0 else
if tmp>255 then result := 255 else