Page 1 of 1
Mixing colors. Mr. Ukoenig
Posted: Wed Jul 30, 2014 12:35 pm
by hmpaquito
Hi Mr. Ukoenig and all:
I would need to replace one color with another in a rgb color.
EXAMPLE. If I have color CLR_HGRAY and I use ChangeColor(CLR_HGRAY, CLR_BLUE) I would expect to get something like a CLR_HBLUE result. That is, the "H" part of CLR_HGRAY (light) give light to CLR_BLUE
ChangeColor(nColor, nColorBase)
Thanks in advance. regards
Re: Mixing colors. Mr. Ukoenig
Posted: Thu Jul 31, 2014 7:31 am
by hmpaquito
1st step (and almost unique step):
Code: Select all | Expand
HARBOUR HB_FUN_BRIGHTNESS( ) // Color
{
COLORREF lColor = hb_parnl(1);
long R = GetRValue(lColor) * 0.299 ;
long G = GetGValue(lColor) * 0.587 ;
long B = GetBValue(lColor) * 0.114 ;
long Brightness = R + G + B ;
hb_retnl( Brightness ) ;
}
Re: Mixing colors. Mr. Ukoenig
Posted: Mon Aug 04, 2014 6:42 pm
by ukoenig
hmpaquito,
the RGB-colorinfo about the brightness
is a value of
0 for the darkest and
255 for the brightest color.
White will return 255
Black will return 0
CLR_GREEN => 32768 => RGB( 0, 128, 0 ) =>
75CLR_HGREEN => 65280 => RGB( 0, 255, 0 ) =>
149Low Intensity colors will return a value from
0 to <
127.5Hight Intensity colors will return a value from >
127.5 to
255You can use the function like :
FUNCTION GET_BRIGHT( nColor )
LOCAL nRGBProz := 0, nBlue, nGreen, nRed
nRed := nRGBRed( nColor )
nGreen := nRGBGreen( nColor )
nBlue := nRGBBlue( nColor )
nBrightness := INT( 0.299 * nRed ;
+ 0.587 * nGreen ;
+ 0.114 * nBlue )
// MsgAlert( nColor, "Color" )
// MsgAlert( nBrightness, "Brightness" ) // 0 - 255
RETURN nBrightness best regards
Uwe

Re: Mixing colors. Mr. Ukoenig
Posted: Tue Aug 05, 2014 7:32 am
by hmpaquito
Mr. Ukoenig,
My second requirement is how to getting a certain amount of brightness from a base color: to make a function Get_MixColorBrightness()
nBrightness: = Get_Brightness (CLR_HGRAY)
nColor: = Get_MixColorBrightness(CLR_GREEN, nBrightness) // nColor will be green but with Brightness nBrightness
Thanks
Re: Mixing colors. Mr. Ukoenig
Posted: Tue Aug 05, 2014 2:29 pm
by ukoenig
Working on my own RGB-tool,
there will be a Bridgtness-adjustment to.
There is still a lot to do, to get it finished.
I noticed in colors.ch
-------------------------
#define CLR_HRED 255 // RGB( 255, 0, 0 )
#define CLR_HMAGENTA 16711935 // RGB( 255, 0, 255 )
#define CLR_HBLUE 16711680 // RGB( 0, 0, 255 )seems to be wrong ( low resolution )
Many extras are included like
preview and infos of all colors in COLORS.ch, a gradient-painter, color-picker...
Infos about a selected color are displayed at the bottom.

Best regards
Uwe
