[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Composite colors...

Hi all

Colors:
-------
Light yellow = $0080FFFF. When I use FloodFill on a Canvas, and read the colors of each pixel, it is a mixture: ie White $00FFFFFF and Yellow $0000FFFF.

Question:
---------
How do I form a composite color if I know the 2 main colors, and vice versa?

Regards
Keith
0
keithcsl
Asked:
keithcsl
1 Solution
 
edeyCommented:
comp := (first_col + second_col)div 2;

or

var
 fr,fg,fb,sr,sg,sb,cr,cg,cb : byte;
begin
 fr := first_col;
 fg := first_col shr 8;
 fb := first_col shr 16;
 sr := second_col;
 sg := second_col shr 8;
 sb := second_col shr 16;

if (fb+sb) >= 512 then
 cb := 255
else
 cb := (fb+sb)div 2;
if (fg+sg) >= 512 then
 cg := 255
else
 cb := (fg+sg)div 2;
if (fr+sr) >= 512 then
 cr := 255
else
 cr := (fr+sr)div 2;

comp_col := cr+(cg shl 8)+(cb shl 16);



Or something like that :)
GL
Mike

0
 
keithcslAuthor Commented:
Thanks

I have posted another question about composite colors...

Keith
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now