|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Color image to Gray Shade ImageHi all,
I'm creating a custom button control. I need to show a color image when the button control is enabled and a gray shade of the same image when the button control is disabled. How can i convert a color image to a gray image in VB 2005. Thanks, Sugan Chennai, INDIA "Sugan" <vsu***@gmail.com> wrote in message Try this:news:1152082297.774317.315540@b68g2000cwa.googlegroups.com... > Hi all, > > I'm creating a custom button control. I need to show a color image when > the button control is enabled and a gray shade of the same image when > the button control is disabled. How can i convert a color image to a > gray image in VB 2005. > > Thanks, > Sugan > Chennai, INDIA Private Function Convert2Greyscale(ByVal BitmapIn As System.Drawing.Bitmap) As System.Drawing.Bitmap Dim newB As Bitmap = CType(BitmapIn.Clone(), Bitmap) Dim bounds As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, newB.Width, newB.Height) Dim clrMatrix As System.Drawing.Imaging.ColorMatrix = New System.Drawing.Imaging.ColorMatrix Dim mX, mY As Integer For mX = 0 To 2 For mY = 0 To 2 clrMatrix(mX, mY) = 0.333333 Next Next Dim imgAttr As System.Drawing.Imaging.ImageAttributes = New System.Drawing.Imaging.ImageAttributes imgAttr.SetColorMatrix(clrMatrix) Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(newB) g.DrawImage(newB, bounds, 0, 0, newB.Width, newB.Height, System.Drawing.GraphicsUnit.Pixel, imgAttr) g.Dispose() Return newB End Function HTH Paul
Multithread Revisted
ulong vs UInt64 Accessing existing Excel instance CheckedListbox backcolor question Removing the " Web Form Designer Generated Code " region after converting from ASP.NET 1.1 to ASP.NE Need help on windows service and timer File.Exists not working. Confused About Dispose and Finalize in VS.Net How to use DataGridComboColumnStyle how to convert htm file to word or excel file with images as in htm |
|||||||||||||||||||||||