|
-
Mar 12th, 2004, 09:11 AM
#1
Thread Starter
Hyperactive Member
DrawImage question [RESOLVED]
Hi Everybody,
I have an form (frmMain) with an picturebox (pctMap) on wich I draw an image (pctPion.Image). I'm using this to draw the Pion on the Map:
VB Code:
Dim gr As Graphics = pctMap.CreateGraphics
gr.DrawImage(pctPion.Image, 42, 42)
But this can only be done in the frmMain code... I've got an class Map wich should do this... How can this be solved? Is it an design error by me !
Extra question: instead of pctPion.Image i would like to use an filename is this possible cause when I try that I get an error?!
Thnx in advance,
Bloged
Last edited by Bloged; Mar 12th, 2004 at 04:37 PM.
-
Mar 12th, 2004, 10:06 AM
#2
Sleep mode
1-I don't quite get what you mean !
2-It's working . What does the error say ?
VB Code:
Me.PictureBox1.Image = New Bitmap("c:\test.jpg")
-
Mar 12th, 2004, 11:33 AM
#3
Thread Starter
Hyperactive Member
VB Code:
Dim gr As Graphics = pctMap.CreateGraphics
gr.DrawImage(pctPion.Image, 42, 42)
This is what I use to draw an image over an image... pctPion.Image over the image of pctMap... now I want to use something like:
VB Code:
gr.DrawImage(c:\test.gif, 42 ,42)
But that won't work...
Also, more important, now this function is in the frmMain code (frmMain also holds the pctMap & pctPion) but I want this function in the Map class so simple said it would look something like this:
VB Code:
Dim gr As Graphics = frmMain.pctMap.CreateGraphics
gr.DrawImage(frmMain.pctPion.Image, 42, 42)
But that doesn't work!
Anyone who knows the answers (and gets what I'm trying to say)
Thnx in advance
Bloged
-
Mar 12th, 2004, 11:40 AM
#4
Sleep mode
Do you have any problems using this way :
VB Code:
gr.DrawImage(New Bitmap("c:\test.gif"), 42, 42)
I still don't know what you mean by "map class" ? Do you mean referencing mainform in your class to use it inside the function?
-
Mar 12th, 2004, 12:29 PM
#5
Thread Starter
Hyperactive Member
This works:
VB Code:
gr.DrawImage(New Bitmap("c:\test.gif"), 42, 42)
By Map class I mean I've got an class called Map:
VB Code:
Public Class Map
End Class
This class is for my form containing the pctMap on wich I want to draw the test.gif
VB Code:
Public Class frmMain
End Class
How can I do that?
Hope this clarifies it more!
Grtz,
Bloged
-
Mar 12th, 2004, 12:33 PM
#6
yay gay
You'll have to pass as argument or your picture or its graphic's pbject
\m/  \m/
-
Mar 12th, 2004, 01:01 PM
#7
Thread Starter
Hyperactive Member
Originally posted by PT Exorcist
You'll have to pass as argument or your picture or its graphic's pbject
Could you explain with some sample code? I'm pretty new to VB .Net
Grtz,
Bloged
-
Mar 12th, 2004, 03:28 PM
#8
Sleep mode
VB Code:
Public Class mytestclass
Public Shared Sub DrawingSub(ByVal frm As Form, ByVal picBox As PictureBox)
Dim gr As Graphics = frm.CreateGraphics
gr.DrawImage(picBox.Image, 42, 42)
End Sub
End Class
'then you just call it from your main form as this :
mytestclass.DrawingSub(Form1, PictureBox1)
-
Mar 12th, 2004, 03:57 PM
#9
Thread Starter
Hyperactive Member
Ok that seems to be it now I've got to test it!
But I get:
'frmMain' is a type and cannot be used as an expression
Sorry real newbie in VB.Net
Edit:
I solved it myself this seems to work:
VB Code:
Public Shared Sub DrawPion(ByVal pctBox As PictureBox)
Dim gr As Graphics = pctBox.CreateGraphics
gr.DrawImage(New Bitmap("c:\pion.gif"), 42, 42)
End Sub
Called with:
Grtz,
Bloged
Last edited by Bloged; Mar 12th, 2004 at 04:20 PM.
-
Mar 12th, 2004, 06:21 PM
#10
Sleep mode
Originally posted by Bloged
Ok that seems to be it now I've got to test it!
But I get:
'frmMain' is a type and cannot be used as an expression
Sorry real newbie in VB.Net
I don't understand why you got that error !!! I used it that and working ok
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
|