Q: image brightness & contrast

This is not necessarily a Delphi question only that it will be
programmed in Delphi.
I am working on a specialised image processor and the client would like
brightness and contrast controls (in grayscale only). I have done
brightness but am having problems with contrast - maybe because its the
end of the week. :)
What I have been working on currently looks like:
tempPixel := 128 + (Row[x] - 128) * ContrastAmount
tempPixel is the new pixel value (the next lines check for out of
Row[x] is the pixel (Row is a ScanLine)
ContrastAmount is either a percentage (-100..100) or similar (ie -
This sort of works for some low, positive contrast values but the
contrast effect is really too much and it causes a negative image with
negative contrast values rather than reducing the contrast.
So basically this is an algorithm question and a search of news and the
net has resulted in me finding some other interesting stuff but not a
solution yet.
DIGITAL PROSPERITY PTY LTD phone: +61 3 9761-3885
P.O. Box 557 fax: +61 3 9761-3811
Boronia, Victoria 3155

Sent via Deja.com http://www.deja.com/
Before you buy.