eramgarden Posted March 28, 2004 Posted March 28, 2004 I have 700x500 canvas. I have an image. how can I center the image on the canvas? If i have: gr.DrawImage(b, 0.0F, 0.0F)..this draws it on the left hand corner of the canvas.. This is what i have: Dim g As Graphics = Graphics.FromImage(b) Dim gr As Graphics = Graphics.FromImage(Canvas) Dim imageH As Single = Convert.ToSingle(b.Height) Dim imageW As Single = Convert.ToSingle(b.Width) Dim CanH As Single = Convert.ToSingle(Canvas.Height) Dim canW As Single = Convert.ToSingle(Canvas.Width) Dim bgBrush = New SolidBrush(System.Drawing.Color.White) gr.FillRectangle(bgBrush, New Rectangle(0, 0, 700, 500)) [b]gr.DrawImage(b, 0.0F, 0.0F)[/b] Any ideas?? Quote
eramgarden Posted March 28, 2004 Author Posted March 28, 2004 found my answer.. (largerectangleW - smallrectangleW) /2...same for height. Quote
Menge Posted March 28, 2004 Posted March 28, 2004 image.y=canvas.height/2-image.height/2 same for height with the X position :) Quote Menge
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.