【发布时间】:2013-08-14 22:37:58
【问题描述】:
大家好,我正在尝试将 4 个框添加到 1280 x 720 的图像中。
我想将框添加到图像的顶部,但将它们均匀地隔开 1280 宽度。
Dim g As Graphics = Graphics.FromImage(image)
g.FillRectangle(New SolidBrush(Color.FromArgb(90, 255, 255, 255)), New Rectangle(3, 7, 270, 25)) 'The transparent square for Date
g.DrawString(Format(DateTime.Now, "MM/dd/yyyy HH:mm:ss tt"), New Font("Arial", 18), Brushes.Black, New PointF(3, 5)) 'The date
g.FillRectangle(New SolidBrush(Color.FromArgb(90, 255, 255, 255)), New Rectangle(350, 7, 170, 25)) 'The transparent square for Latitude
g.DrawString("Lat: " & "30.976154", New Font("Arial", 18), Brushes.Black, New PointF(352, 5))
g.FillRectangle(New SolidBrush(Color.FromArgb(90, 255, 255, 255)), New Rectangle(670, 7, 180, 25)) 'The transparent square for longitude
g.DrawString("Lng: " & "33.351328", New Font("Arial", 18), Brushes.Black, New PointF(672, 5))
g.FillRectangle(New SolidBrush(Color.FromArgb(90, 255, 255, 255)), New Rectangle(970, 7, 120, 25)) 'The transparent square for MPH
g.DrawString("MPH: " & "000", New Font("Arial", 18), Brushes.Black, New PointF(972, 5))
g.Dispose()
但是我还没有找到一种可靠的方法来使它们在屏幕上均匀分布,因为每个矩形/文本的宽度都与其周围的宽度不同。
任何想法,想法都会很棒!
【问题讨论】:
-
不清楚您要做什么。你想让盒子都均匀分布吗?还是您希望它们始终与其中的字符串长度成正比?你想达到什么目的?图片可能会有所帮助。
-
@user1118321 将它们均匀地隔开。
标签: vb.net graphics system.drawing rectangles aforge