0

hi everyone. I have written a program that convert from color image to gray image in asp.net with visual basic, but I have a problem am new in asp.net and I want to display the gray image but I don't know how. please help me. this is a code.

If (FileUpload1.HasFile) Then
            FileUpload1.SaveAs(MapPath(FileUpload1.FileName))
            Image1.ImageUrl = FileUpload1.FileName
        End If
        Dim current As Bitmap = New Bitmap(Server.MapPath(Image1.ImageUrl))
        Dim pic1 As Bitmap = New Bitmap(current)
        Dim gray As Bitmap = New Bitmap(pic.Width - 1, pic.Height - 1)
        For a = 0 To (pic1.Width) - 1
            For b = 0 To (pic1.Width) - 1
                Dim c As Color = pic1.GetPixel(a, b)
                Dim rx As Single = c.R
                Dim g As Single = c.G
                Dim b1 As Single = c.B
                Dim d As Integer = CInt(rx * 0.3 + g * 0.5 + b1 * 0.11)
                gray.SetPixel(a, b, Color.FromArgb(d, d, d))
            Next
        Next
3
Contributors
2
Replies
16
Views
2 Years
Discussion Span
Last Post by madCoder
1

Maybe this could help? It's someone who made a basic webpage and implemented ASP.NET into it. If you click the button the color of what I think is the muslim prayer buildings will change to gray by ASP function that has also been presented and explained. I looked at your code and the code on website, they're similiar in some way, but are not exactly same.

Edited by Aeonix

0

What problem are you having? From what I see of your code sample, the original uploaded image might display (though I'm not sure what URL is getting generated.)

The changes you make to the Bitmap are all happening in memory. They are not altering the image file on the web server. Once you are done with the transformation, you need to put the resulting image someplace the web server can reach it -- such as saving it into "~/images/gray/" and then pointing Image1 to that URL.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.