devxlogo

GetGreyScaleImage – Convert a bitmap to greyscale

GetGreyScaleImage – Convert a bitmap to greyscale

' Convert a bitmap to greyscale - the function returns a new bitmap,'  it does not directly modify the input image.' Note: requires the GetGreyScale function'' Example:'    Dim bmp As New Bitmap("D:sample.gif")'    PictureBox1.Image = GetGreyScaleImage(bmp)Function GetGreyScaleImage(ByRef bmp As Bitmap) As Bitmap    ' create a new empty bitmap with the same size of the original bitmap    Dim newBmp As New System.Drawing.Bitmap(bmp.Width, bmp.Height)    Dim x, y As Integer    ' draw the new bitmap pixel-by-pixel, by converting to greyscale the pixels     ' in the original bitmap    For x = 1 To bmp.Width - 1        For y = 1 To bmp.Height - 1            newBmp.SetPixel(x, y, GetGreyScale(bmp.GetPixel(x, y)))        Next    Next    Return newBmpEnd Function

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist