Перевести код из VB6 - Visual Basic .NET

Узнай цену своей работы

Формулировка задачи:

Здравствуйте. Переведите пожалуйста код на vb .net

Решение задачи: «Перевести код из VB6»

textual
Листинг программы
Option Strict On
Imports System.Drawing
Public Class Form1
 
    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        Dim x, Y, c, r, g, b, threshold As Integer
        Dim blackPen As New Pen(Color.Black, 1)
        Dim whitePen As New Pen(Color.White, 1)
        Dim myGraphics As Graphics = MyBase.CreateGraphics()
        Dim bmp As New Bitmap("C:\x40.jpg")
 
        threshold = 20
 
        For Y = 0 To Me.Height
            For x = 0 To Me.Width
 
                'c = Me.BackColor.GetHashCode
                c = bmp.GetPixel(x, Y).GetHashCode
 
                r = c And &HFF
                g = (c \ &H100) And &HFF
                b = (c \ &H10000) And &HFF
 
                If (r - b) > threshold And (r - g) > threshold Then
                    'PSet (x, Y), vbWhite
                    myGraphics.DrawEllipse(whitePen, x, Y, 1, 1)
                Else
                    'PSet (x, Y), 0
                    myGraphics.DrawEllipse(blackPen, x, Y, 1, 1)
                End If
 
            Next
        Next
 
    End Sub

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

6   голосов , оценка 4.333 из 5