|
-
Jan 23rd, 2000, 10:06 AM
#1
Thread Starter
Registered User
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
-
Jan 23rd, 2000, 11:53 AM
#2
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.
Code:
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
[email protected]
[email protected]
-
Jan 23rd, 2000, 11:13 PM
#3
Thread Starter
Registered User
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|