Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

firlefanz

Big problem with Canvas.Pixels, Small sample included

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!