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
Mixing colors. Mr. Ukoenig
Re: Mixing colors. Mr. Ukoenig
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
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 ) => 75
CLR_HGREEN => 65280 => RGB( 0, 255, 0 ) => 149
Low Intensity colors will return a value from 0 to < 127.5
Hight Intensity colors will return a value from > 127.5 to 255
You 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![Laughing :lol:](./images/smilies/icon_lol.gif)
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 ) => 75
CLR_HGREEN => 65280 => RGB( 0, 255, 0 ) => 149
Low Intensity colors will return a value from 0 to < 127.5
Hight Intensity colors will return a value from > 127.5 to 255
You 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
![Laughing :lol:](./images/smilies/icon_lol.gif)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: Mixing colors. Mr. Ukoenig
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
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
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.
![Image](http://www.pflegeplus.com/IMAGES/Rgb1.jpg)
Best regards
Uwe![Laughing :lol:](./images/smilies/icon_lol.gif)
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.
![Image](http://www.pflegeplus.com/IMAGES/Rgb1.jpg)
Best regards
Uwe
![Laughing :lol:](./images/smilies/icon_lol.gif)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.