الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

شرح كود مقارنة الصور

بدأه م/ كريم في 17 نوفمبر 2009 · 1 رد · 1,285 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ممكن حد يشرح لي الكود الموجود بالموضوع لو سمحتم خصوصا ان الدكتور اعطاه لنا ولكن للاسف ما فهمت منه شي ومحتاج شرح للكود عشان افهمه :wub:


Application.DoEvents()

' Load the images.
Dim bm1 As Bitmap = Image.FromFile(txtFile1.Text)
Dim bm2 As Bitmap = Image.FromFile(txtFile2.Text)

' Make a difference image.
Dim wid As Integer = Math.Min(bm1.Width, bm2.Width)
Dim hgt As Integer = Math.Min(bm1.Height, bm2.Height)
Dim bm3 As New Bitmap(wid, hgt)

' Create the difference image.
Dim are_identical As Boolean = True
Dim r1, g1, b1, r2, g2, b2, r3, g3, b3 As Integer
Dim eq_color As Color = Color.White
Dim ne_color As Color = Color.Red
For x As Integer = 0 To wid - 1
For y As Integer = 0 To hgt - 1
If bm1.GetPixel(x, y).Equals(bm2.GetPixel(x, y)) Then
bm3.SetPixel(x, y, eq_color)
Else
bm3.SetPixel(x, y, ne_color)
are_identical = False
End If
Next y
Next x

' Display the result.
picResult.Image = bm3

Me.Cursor = Cursors.Default
If (bm1.Width <> bm2.Width) OrElse (bm1.Height <> bm2.Height) Then are_identical = False
If are_identical Then
MessageBox.Show("The images are identical")
Else
MessageBox.Show("The images are different")
End If

bm1.Dispose()
bm2.Dispose()
End Sub
Me.Cursor = Cursors.WaitCursor

#2

الدكتور قام بالتعليق على كل مقتطف من الكود, لم لا تبدأ بتحليل كل سطر منه و البحث عن العمل الذي يقوم به ثم تكتب تحليلك كتعليق على كل سطر. في الأخير سترى أنك تستطيع فهمه لوحدك بدون مساعدة :)

تلميحة : و أنت على محرر فيجوال ستوديو, إذا لم تفهم معنى أي كلمة, قم بتحريك مؤشر التحرير فوق الكلمة ثم انقر على F1 لفتح MSDN على الصفحة المخصصة للمعرف حيث ستجد المساعدة فإذا لم تجد فجوجل.

بالتوفيق :)

مواضيع مشابهة