Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

color to b & w 1

Status
Not open for further replies.

KenshinHimura

Programmer
May 8, 2003
91
US
how would you change color to black and white?
 
FOR... SCREEN 13?

Try this...

FOR C = 0 TO 255
PALGET C, R, G, B
R = (R + G + B) \ 3
PALSET C, R, R, R
NEXT

Sub PALGET(C, R, G, B)
OUT &H3C7, C
R = INP(&H3C9)
G = INP(&H3C9)
B = INP(&H3C9)
End Sub

Sub PALSET(C, R, G, B)
OUT &H3C8, C
OUT &H3C9, R
OUT &H3C9, G
OUT &H3C9, B
End Sub


Let me know if this is what you meant or if you need something different...

Good Luck...;-)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
Yep thats exatly what I wanted thx a lot. BTW could you explain to me why that works. I get the changing the pallette using out but how does it change it to b & w?
 
Grey Scale is the shades of Grey between black and white...

White is when Red, Green, & Blue are all equal to 255 or FF in Hex...

When Red, Green, & Blue Are Equal to 0, the color is Black...

All of the shades in between those colors are known as grey...

For a color to be Grey, All of the colors (Red, Green, And Blue) All need to be equal to each other...

Red, Green, Blue level is known as RGB

The Lowest Byte is Red
The Middle Byte is Green
The Highest Byte is Blue...

So..
If Red = 255 (FF Hex)
Green = 127 (7F Hex)
& Blue = 63 (3F Hex)

the RGB level is &H3F7FFF or 4161535

or... Red + Green * 256 + Blue * 256^2

So to get the grey scale (black and white) from a color picture, you take the color values, average them, and write all 3 back as the same number...

So, in this case you Take 255 + 127 + 63 and dive it by 3...
Which is 148 (94 hex)

So.. The Grey Value for the color is &H949494 or 9737364

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top