JeffSM
Jan 23rd, 2000, 09:06 AM
How do I gray pictures! I use small pictureboxes 16x16 bitmaps in may app, and I wish gray them like a graphic button disabled or like IE menus!
Some suggestions!
Jefferson
Aaron Young
Jan 23rd, 2000, 10:53 AM
Most Apps will have a Pre-Drawn Greyed Equivelant of each Menu/Toolbar Item, but you can easily convert a Picture to Grey Scale by Calculating the Grey Value of Each Pixel, ie.
Private Sub Command1_Click()
Dim iX As Integer
Dim iY As Integer
Dim iXPixel As Integer
Dim iYPixel As Integer
With Picture1
.ScaleMode = vbPixels
iX = ScaleX(.Picture.Width, vbHimetric, vbPixels)
iY = ScaleY(.Picture.Height, vbHimetric, vbPixels)
For iYPixel = 0 To iY
For iXPixel = 0 To iX
'Convert each Pixel to its Grey Equivelant.
Picture1.PSet (iXPixel, iYPixel), GetGreyColor(.Point(iXPixel, iYPixel))
Next
Next
End With
End Sub
Public Function GetGreyColor(ByVal lRGB As Long) As Long
Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer
Dim lGrey As Long
'Extract the RGB Components
iRed = lRGB And vbRed
iGreen = (lRGB And vbGreen) / (2 ^ 8)
iBlue = (lRGB And vbBlue) / (2 ^ 16)
'Set the Grey Color to the Mean Value of the Components
lGrey = (iRed + iGreen + iBlue) / 3
GetGreyColor = RGB(lGrey, lGrey, lGrey)
End Function
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com