FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Mixing colors. Mr. Ukoenig
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Mixing colors. Mr. Ukoenig
Posted: Wed Jul 30, 2014 12:35 PM

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

Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Mixing colors. Mr. Ukoenig
Posted: Thu Jul 31, 2014 07:31 AM
1st step (and almost unique step):
Code (fw): Select all Collapse
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 ) ;
}
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Mixing colors. Mr. Ukoenig
Posted: Mon Aug 04, 2014 06:42 PM
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 :-)
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.
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Mixing colors. Mr. Ukoenig
Posted: Tue Aug 05, 2014 07:32 AM

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

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Mixing colors. Mr. Ukoenig
Posted: Tue Aug 05, 2014 02:29 PM
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 :-)
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.

Continue the discussion