|
-
Mar 22nd, 2004, 05:45 PM
#1
Thread Starter
Hyperactive Member
Easy DrawImage question [RESOLVED]
He everyone,
I'm using this to draw an pion on my map:
VB Code:
Dim gr As Graphics = pctBox.CreateGraphics
gr.DrawImage(New Bitmap("c:\pion.gif"), iX, iY)
But I want to use something like
VB Code:
Dim gr As Graphics = pctBox.CreateGraphics
gr.DrawImage(New Bitmap(sString), iX, iY)
Where sString contains something like c:\pion.gif
I tried
VB Code:
Dim gr As Graphics = pctBox.CreateGraphics
gr.DrawImage(New Bitmap("sString"), iX, iY)
With no luck!
Thanks in advance
Grtz,
Bloged
Last edited by Bloged; Mar 23rd, 2004 at 05:35 PM.
-
Mar 22nd, 2004, 07:02 PM
#2
Sleep mode
Like this !!
VB Code:
Sub DrawImg(ByVal pth As String)
Dim g As Graphics = Me.PictureBox1.CreateGraphics
g.DrawImage(New Bitmap(pth), 0, 0)
End Sub
'Then
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
DrawImg("c:\test.jpg")
End Sub
-
Mar 22nd, 2004, 07:20 PM
#3
Thread Starter
Hyperactive Member
Something like that! This is the source as I'm wanting it (or something similair):
VB Code:
Shared cooCoordinates(100) As Coordinate
'(Re)draws all the pions on the map
Public Shared Function DrawAllPions(ByRef pioPion() As Pion, ByVal pctBox As PictureBox)
Dim iLoop, iX, iY As Integer
For iLoop = 0 To 39
iX = Coordinate2Pixel(pioPion(iLoop).GetCoordinateX())
iY = Coordinate2Pixel(pioPion(iLoop).GetCoordinateY())
Dim gr As Graphics = pctBox.CreateGraphics
gr.DrawImage(New Bitmap(pioPion(iLoop).PicturePath), iX, iY)
Next
End Function
VB Code:
Public Class Pion
'Returns the path with the picture for this image
Public ReadOnly Property PicturePath() As String
Get
Return AppDomain.CurrentDomain.BaseDirectory & "images\pion.gif"
End Get
End Property 'PicturePath
End Class
Grtz,
Bloged
Last edited by Bloged; Mar 22nd, 2004 at 07:23 PM.
-
Mar 22nd, 2004, 07:28 PM
#4
Sleep mode
I don't understand why you're doing it that way ! . Are you getting any error anyway ??
-
Mar 22nd, 2004, 07:40 PM
#5
Thread Starter
Hyperactive Member
This is only for testing
VB Code:
Public Class Pion
'Returns the path with the picture for this image
Public ReadOnly Property PicturePath() As String
Get
Return AppDomain.CurrentDomain.BaseDirectory & "images\pion.gif"
End Get
End Property 'PicturePath
End Class
and should become something like
VB Code:
Public Class Pion
Dim intRank as Integer
'Returns the path with the picture for this image
Public ReadOnly Property PicturePath() As String
Get
Return AppDomain.CurrentDomain.BaseDirectory & "images\pion" & intRank & ".gif"
End Get
End Property 'PicturePath
End Class
Grtz,
Bloged
-
Mar 23rd, 2004, 05:36 PM
#6
Thread Starter
Hyperactive Member
Solved it myself... Made an type instead of pion.gif I called the file poin.gif
Thanks for the help though!
Grtz,
Bloged
-
Mar 23rd, 2004, 06:06 PM
#7
Sleep mode
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|