I am new to .net but want to use this vb6 code in vb.net (no success ofcourse) but what to change and all? :s
what it does is convert a grayscale image to have an rgb value and make it a real color like a more red like color or so.
VB Code:
Public layout_color(2) As Integer Public layout_red As Integer Public layout_green As Integer Public layout_blue As Integer Public Sub obtainRGB(cValue) layout_color(0) = Int(cValue / 65536) + layout_red cValue = cValue Mod 65536 layout_color(1) = Int(cValue / 256) + layout_green cValue = cValue Mod 256 layout_color(2) = cValue + layout_blue If layout_color(0) < 0 Then layout_color(0) = 0: If layout_color(0) > 255 Then layout_color(0) = 255 If layout_color(1) < 0 Then layout_color(1) = 0: If layout_color(1) > 255 Then layout_color(0) = 255 If layout_color(2) < 0 Then layout_color(2) = 0: If layout_color(2) > 255 Then layout_color(2) = 255 End Sub Public Sub layout_convert(red As Integer, green As Integer, blue As Integer) Dim X As Long: Dim Y As Long layout_red = red: layout_green = green: layout_blue = blue For Y = 0 To cmd_image_orig.Height - 1 For X = 0 To cmd_image_orig.Width - 1 obtainRGB (cmd_image_orig.Point(X, Y)) cmd_image_new.PSet (X, Y), RGB(layout_color(0), layout_color(1), layout_color(2)) DoEvents Next X Next Y end sub
the above code work 100% correctly but how can i make such a thing in .net? this is how far i got ...
VB Code:
Public layout_color(2) As Integer Public layout_red As Integer Public layout_green As Integer Public layout_blue As Integer Dim myBitmap As System.Drawing.Bitmap Dim tmpColor As System.Drawing.Color Public Sub obtainRGB(ByVal cValue) layout_color(0) = Int(cValue / 65536) + layout_red cValue = cValue Mod 65536 layout_color(1) = Int(cValue / 256) + layout_green cValue = cValue Mod 256 layout_color(2) = cValue + layout_blue If layout_color(0) < 0 Then layout_color(0) = 0 : If layout_color(0) > 255 Then layout_color(0) = 255 If layout_color(1) < 0 Then layout_color(1) = 0 : If layout_color(1) > 255 Then layout_color(0) = 255 If layout_color(2) < 0 Then layout_color(2) = 0 : If layout_color(2) > 255 Then layout_color(2) = 255 '// From here on i am stuck End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim X As Long : Dim Y As Long layout_red = 255 : layout_green = 0 : layout_blue = 0 For Y = 0 To Picture1.Height - 1 For X = 0 To Picture1.Width - 1 tmpColor = myBitmap.GetPixel(X, Y) ' from here i am stuck too myBitmap.SetPixel(X, Y, tmpColor) Next X Next Y End Sub but does not work at all




Reply With Quote