Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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??

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...