Results 1 to 7 of 7

Thread: Easy DrawImage question [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330

    Easy DrawImage question [RESOLVED]

    He everyone,

    I'm using this to draw an pion on my map:

    VB Code:
    1. Dim gr As Graphics = pctBox.CreateGraphics
    2. gr.DrawImage(New Bitmap("c:\pion.gif"), iX, iY)

    But I want to use something like
    VB Code:
    1. Dim gr As Graphics = pctBox.CreateGraphics
    2. gr.DrawImage(New Bitmap(sString), iX, iY)

    Where sString contains something like c:\pion.gif

    I tried
    VB Code:
    1. Dim gr As Graphics = pctBox.CreateGraphics
    2. 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.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Like this !!
    VB Code:
    1. Sub DrawImg(ByVal pth As String)
    2.         Dim g As Graphics = Me.PictureBox1.CreateGraphics
    3.         g.DrawImage(New Bitmap(pth), 0, 0)
    4.     End Sub
    5.  
    6.  
    7. 'Then
    8.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal
    9. e As System.EventArgs) Handles Button1.Click
    10.         DrawImg("c:\test.jpg")
    11.     End Sub

  3. #3

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Something like that! This is the source as I'm wanting it (or something similair):

    VB Code:
    1. Shared cooCoordinates(100) As Coordinate
    2.  
    3. '(Re)draws all the pions on the map
    4. Public Shared Function DrawAllPions(ByRef pioPion() As Pion, ByVal pctBox As PictureBox)
    5.     Dim iLoop, iX, iY As Integer
    6.  
    7.     For iLoop = 0 To 39
    8.         iX = Coordinate2Pixel(pioPion(iLoop).GetCoordinateX())
    9.         iY = Coordinate2Pixel(pioPion(iLoop).GetCoordinateY())
    10.  
    11.         Dim gr As Graphics = pctBox.CreateGraphics
    12.         gr.DrawImage(New Bitmap(pioPion(iLoop).PicturePath), iX, iY)
    13.     Next
    14. End Function

    VB Code:
    1. Public Class Pion
    2.     'Returns the path with the picture for this image
    3.     Public ReadOnly Property PicturePath() As String
    4.         Get
    5.             Return AppDomain.CurrentDomain.BaseDirectory & "images\pion.gif"
    6.         End Get
    7.     End Property    'PicturePath
    8. End Class

    Grtz,

    Bloged
    Last edited by Bloged; Mar 22nd, 2004 at 07:23 PM.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't understand why you're doing it that way ! . Are you getting any error anyway ??

  5. #5

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    This is only for testing
    VB Code:
    1. Public Class Pion
    2.     'Returns the path with the picture for this image
    3.     Public ReadOnly Property PicturePath() As String
    4.         Get
    5.             Return AppDomain.CurrentDomain.BaseDirectory & "images\pion.gif"
    6.         End Get
    7.     End Property    'PicturePath
    8. End Class
    and should become something like
    VB Code:
    1. Public Class Pion
    2.     Dim intRank as Integer
    3.  
    4.     'Returns the path with the picture for this image
    5.     Public ReadOnly Property PicturePath() As String
    6.         Get
    7.             Return AppDomain.CurrentDomain.BaseDirectory & "images\pion" & intRank & ".gif"
    8.         End Get
    9.     End Property    'PicturePath
    10. End Class

    Grtz,

    Bloged

  6. #6

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Solved it myself... Made an type instead of pion.gif I called the file poin.gif

    Thanks for the help though!

    Grtz,

    Bloged

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Bloged
    Solved it myself... Made an type instead of pion.gif I called the file poin.gif

    Thanks for the help though!
    Grtz,
    Bloged
    lol , pretty simple , I thought you're doing something fancy .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width