Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • 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

NodeBB

  1. Home
  2. Programmation
  3. Développement de logiciels
  4. VB.Net
  5. Choisir l'emplacment exact d'une image dans une picturbox

Choisir l'emplacment exact d'une image dans une picturbox

Scheduled Pinned Locked Moved VB.Net
2 Posts 2 Posters 2.2k Views
  • 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.
  • mars073M
    mars073M
    mars073
    wrote on last edited by
    #1

    <p>Shalut all,<br/>
    je vais vous faire un tuto rapide pour placer une image dans une picturebox, je sais y a l'option padding ou magrin je sais pu.. mais avec on une peu pas mettre une position négative !<br/><br/>
    pour cela on va faire 2fonctions :</p>
    <pre class="ipsCode prettyprint lang-auto">
    #Region "fonctions"
    Private Function SetPictureAtPoint(ByVal FinalImageSize As System.Drawing.Size, ByVal Image As System.Drawing.Image, ByVal Location As System.Drawing.Point) As System.Drawing.Image
    Dim TmpImg As System.Drawing.Image = New System.Drawing.Bitmap(FinalImageSize.Width, FinalImageSize.Height)
    Dim Graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(TmpImg)
    Graphics.DrawImage(Image, Location)
    Return TmpImg
    End Function
    Private Function SetPictureAtPoint(ByVal Image As System.Drawing.Image, ByVal Location As System.Drawing.Point) As System.Drawing.Image
    Dim TmpImg As System.Drawing.Image = New System.Drawing.Bitmap(Location.X + Image.Width, Location.Y + Image.Height)
    Dim Graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(TmpImg)
    Graphics.DrawImage(Image, Location)
    Return TmpImg
    End Function
    #End Region</pre>
    <p>et puis dans Form.load on va mettre:</p>
    <pre class="ipsCode prettyprint lang-auto">
    Dim Img As New Bitmap(My.Resources.bomb)
    Me.PictureBox1.Image = SetPictureAtPoint(Img, New System.Drawing.Point(0, -20))</pre>
    <p>donc en rouge votre ressource<br/>
    et en vert la position x,y de votre image.<br/><br/>
    EDIT: petite image cadeau xD<br/>
    pour picturebox de 20Px/20Px<br/><img alt="bomb-30c18c6.png" src="<base_url>/applications/sslimageproxy/interface/image.php?url=http://img66.xooimage.com/files/8/3/e/bomb-30c18c6.png"/><br/><br/>
    Voilà un petit tuto rapide je fais peut-être le refaire mais bon 😛 <br/>
    bonne programmation à tous 😄 <br/>
    cordialement,<br/>
    Mars</p>

    Aide à l'apprentissage et la réalisation pour des graphismes, des programmes, des sites ou autres.Signature aléatoire, proposez vous aussi une signature ici!

    1 Reply Last reply
    1
    • AzadA
      AzadA
      Azad
      wrote on last edited by
      #2

      <p>Merci du partage, +1 rep. 🙂 </p>

      Administrateur du forum.
      Contactez-moi par message privé ou par mail.

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

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