Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Image Center

Image Center

Scheduled Pinned Locked Moved Visual Basic
graphicsquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eramgarden
    wrote on last edited by
    #1

    I have 700x500 canvas. I have an image. [b] how can I center the image on the canvas?[b] If i have: [b]gr.DrawImage(b, 0.0F, 0.0F)[/b]..this draws it on the left hand corner of the canvas.. This is what i have: [code] 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)) gr.DrawImage(b, 0.0F, 0.0F) [/code] any ideas?

    E 1 Reply Last reply
    0
    • E eramgarden

      I have 700x500 canvas. I have an image. [b] how can I center the image on the canvas?[b] If i have: [b]gr.DrawImage(b, 0.0F, 0.0F)[/b]..this draws it on the left hand corner of the canvas.. This is what i have: [code] 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)) gr.DrawImage(b, 0.0F, 0.0F) [/code] any ideas?

      E Offline
      E Offline
      eramgarden
      wrote on last edited by
      #2

      found my answer.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups