Big problem with Canvas.Pixels, Small sample included
Hello,
can anybody help me with this one?
For my own painter program I want to have a drawing method, to draw existing pixels brighter/darker. that makes it easier to make it look more 3d style.
i have a little sample program, source included.
Paint sample
http://www.ericbehme.de\samplepaint.zip
Just move the trackbar to -5 or +5 and draw on the bigger picture using mouse (left click) where the color is not black. the pixels will become brighter or darker.
This works for values (trackbar) -5,-4,+4,+5 but not for the other values, it can't work for 0.
There is a function (farbig) which takes the pixels rgb value and makes them brighter/darker, the result seems to be ok, but I only see in the picture the bigger changes, even if I set it to -2 and click on the same pixel 10 times.
this is really very important for me, can anybody help me out?
That would be great, thanks!
Visit my homepage www.ericbehme.de
Don't miss the download section
Hello
I modified the Farbig function and it now reads.....
function tform1.Farbig(Alt:Tcolor;Abweich:extended):tcolor;
//changed---------------------------
var rot,gruen,blau: integer;
ges:extended;
//-----------------------------------
ra,ga,ba: extended;
farb,fsub: string;
begin
ra:=0;
ga:=0;
ba:=0;
blau:=getbvalue(alt);
gruen:=getgvalue(alt);
rot:=getrvalue(alt);
//----------------changed---------------
ges:=(rot+blau+gruen)/3;
//---------------------------------------
if rot>0 then ra:=rot/ges;
if gruen>0 then ga:=gruen/ges;
if blau>0 then ba:=blau/ges;
if blau>0 then blau:=blau+round(ba*abweich);
if rot>0 then rot:=rot+round(ra*abweich);
if gruen>0 then gruen:=gruen+round(ga*abweich);
if blau>255 then blau:=255;
if blau<0 then blau:=0;
if rot>255 then rot:=255;
if rot<0 then rot:=0;
if gruen>255 then gruen:=255;
if gruen<0 then gruen:=0;
result:=rgb(rot,gruen,blau);
end;
The division by ges was too harsh and suppressed small increases.
Hope this helps
Stevie
Don''t follow me, I''m lost.
I modified the Farbig function and it now reads.....
function tform1.Farbig(Alt:Tcolor;Abweich:extended):tcolor;
//changed---------------------------
var rot,gruen,blau: integer;
ges:extended;
//-----------------------------------
ra,ga,ba: extended;
farb,fsub: string;
begin
ra:=0;
ga:=0;
ba:=0;
blau:=getbvalue(alt);
gruen:=getgvalue(alt);
rot:=getrvalue(alt);
//----------------changed---------------
ges:=(rot+blau+gruen)/3;
//---------------------------------------
if rot>0 then ra:=rot/ges;
if gruen>0 then ga:=gruen/ges;
if blau>0 then ba:=blau/ges;
if blau>0 then blau:=blau+round(ba*abweich);
if rot>0 then rot:=rot+round(ra*abweich);
if gruen>0 then gruen:=gruen+round(ga*abweich);
if blau>255 then blau:=255;
if blau<0 then blau:=0;
if rot>255 then rot:=255;
if rot<0 then rot:=0;
if gruen>255 then gruen:=255;
if gruen<0 then gruen:=0;
result:=rgb(rot,gruen,blau);
end;
The division by ges was too harsh and suppressed small increases.
Hope this helps
Stevie
Don''t follow me, I''m lost.
Thank you very much Stevie.
The main problem was 16bit are too less colors, I changed my pixelformat to 24 bit, and now every rgb-Value works perfect, even very little changes.
The main problem was 16bit are too less colors, I changed my pixelformat to 24 bit, and now every rgb-Value works perfect, even very little changes.
My tests were done in 24 Bits and the small increases were killed by the division by the sum of the colours.
Anyway, glad to have helped.
Stevie
Don''t follow me, I''m lost.
Anyway, glad to have helped.
Stevie
Don''t follow me, I''m lost.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement