掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
PictureBoxに多角形を描画 (ID:148177)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Transformを使用しないで計算する例 x座標の最小値、y座標の最大値を画像の(0,0)に合わせ 拡大、縮小は縦横比をかえず両方が収まるように計算 Dim ps As Point() = {New Point(-21700, 50000), _ New Point(-21700, 50250), New Point(-21350, 50250), _ New Point(-21350, 50000)} g.Clear(Color.White) Dim gw = PictureBox1.Width - 1 'g.VisibleClipBounds.Width - 1 Dim gh = PictureBox1.Height - 1 ' g.VisibleClipBounds.Height - 1 Dim NotSet As Boolean = True Dim minx As Integer Dim maxx As Integer Dim miny As Integer Dim maxy As Integer For Each pt In ps If NotSet OrElse minx > pt.X Then minx = pt.X End If If NotSet OrElse maxx < pt.X Then maxx = pt.X End If If NotSet OrElse miny > pt.Y Then miny = pt.Y End If If NotSet OrElse maxy < pt.Y Then maxy = pt.Y End If NotSet = False Next Dim scx = gw / (maxx - minx) Dim scy = gh / (maxy - miny) Dim sc = Math.Min(scx, scy) Dim psf = (From pt In ps Select New PointF(CSng((pt.X - minx) * sc), CSng((-pt.Y + maxy) * sc))).ToArray g.DrawPolygon(Pens.Black, psf)
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.