Mixing colors. Mr. Ukoenig

Mixing colors. Mr. Ukoenig

Postby hmpaquito » 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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Mixing colors. Mr. Ukoenig

Postby hmpaquito » Thu Jul 31, 2014 7:31 am

1st step (and almost unique step):
Code: Select all  Expand view  RUN

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 ) ;
}
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Mixing colors. Mr. Ukoenig

Postby ukoenig » Mon Aug 04, 2014 6: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 :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Mixing colors. Mr. Ukoenig

Postby hmpaquito » Tue Aug 05, 2014 7: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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Mixing colors. Mr. Ukoenig

Postby ukoenig » Tue Aug 05, 2014 2: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.

Image

Best regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 105 guests