Choisir l'emplacment exact d'une image dans une picturbox
-
<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>
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
</p>