vb.net - Find Bounds of GDI+ Shape -
hi i'm trying rectangle surrounds shape drawn via gdi+ when pen thick.
this test code demo added mybase.load test out..
dim bmp new bitmap(500, 500) dim g graphics = graphics.fromimage(bmp) g.clear(color.transparent) g.smoothingmode = smoothingmode.highquality g.pixeloffsetmode = pixeloffsetmode.default ' setup matrix dim mat new matrix mat.translate(100, 100) g.transform = mat ' draw lines , fill dim gp new graphicspath gp.addlines({new point(50, 0), new point(100, 100), new point(0, 100)}) gp.closeallfigures() ' closes open path (ie bring together origin) g.fillpath(new solidbrush(color.beige), gp) ' add together border graphics path g.drawpath(new pen(new solidbrush(color.black), 20), gp) g.drawrectangle(new pen(new solidbrush(color.red), 1), rectangle.truncate(gp.getbounds)) ' tidy g.resettransform() mat.dispose() ' set picturebox value picturebox1.image = bmp
i'd post image forum doesn't allow me.
i want bounding rectangle include pen width too. used above triangle demo cant add together penwidth/2.
any ideas?
julian
if sufficient needs can set pen's .alignment
property inset
so:
g.drawpath(new pen(new solidbrush(color.black), 20) {.alignment = penalignment.inset}, gp)
this tells pen draw on within of path @ times. default draws on middle leads situation outside width @ edges dependant on angle of edge.
result is:
vb.net
No comments:
Post a Comment