24-11-17, 01:42 PM
حل أخر
حيث هنا نستطيع تحديد عدد خلايا الجريد
ايضا عملية الرسم تتم بحيث تكون ابعاد الخلايا متناسبة مع أبعاد الصورة
أيضا نستطيع ان نتحكم في ابعاد الخلية الواحدة
ايضا نستطيع أن نتحكم في شفافية اللون المستخدم في رسم الجريد
الكود كاملا
حيث هنا نستطيع تحديد عدد خلايا الجريد
ايضا عملية الرسم تتم بحيث تكون ابعاد الخلايا متناسبة مع أبعاد الصورة
أيضا نستطيع ان نتحكم في ابعاد الخلية الواحدة
ايضا نستطيع أن نتحكم في شفافية اللون المستخدم في رسم الجريد
الكود كاملا
PHP كود :
Dim bmp As Bitmap = My.Resources.rm
Dim sourceColor As Color = Color.Blue
Dim horizCellNumber As Integer = 8
Dim vertCellNumber As Integer = 8
Dim alpha As Byte = 150
alpha = Byte.MaxValue - alpha
Dim gridColor As Color = Color.FromArgb(CInt((1 - (alpha / Byte.MaxValue)) * Byte.MaxValue), sourceColor)
Dim cellSizeW As Single = bmp.Width / horizCellNumber
Dim cellSizeH As Single = bmp.Height / vertCellNumber
Using g As Graphics = Graphics.FromImage(bmp)
Dim clip As RectangleF = g.VisibleClipBounds
Using cellPen As New Pen(gridColor)
Dim x As Single = clip.Left + cellSizeW
While x < clip.Right
g.DrawLine(cellPen, x, clip.Top, x, clip.Bottom)
x += cellSizeW
End While
Dim y As Single = clip.Top + cellSizeH
While y < clip.Bottom
g.DrawLine(cellPen, clip.Left, y, clip.Right, y)
y += cellSizeH
End While
g.DrawRectangle(cellPen, New Rectangle(clip.Left, clip.Top, clip.Width - 1, clip.Height - 1))
End Using
End Using
PictureBox1.Image = bmp
Retired

