|
-
Sep 20th, 2002, 04:33 PM
#1
Thread Starter
New Member
Extending a Graphics object's VisibleClipBounds
Hello,
I'm a somewhat experienced VB programmer and I've just switched to VB .net, and I'm having a few difficulties. I'm currently coding some kind of level editor for a game I plan to make. Basically, the levels are composed of a bunch of polygons that represent terrain (drawn on a form), which will eventually be rendered. My program is at its very early stages. Ok, so enough of the jiba jaba and straight to point... My problem is, the rectangular drawing space on my form is too small. I'd like to make it as big as the form itself. I believe the property responsible for this is my Graphics object's VisibleClipBounds property. I'm pretty sure of it. The problem is I don't know how to set these visible clip bounds! I tried ' g.VisibleClipBounds.Size.Width = value ' and stuff like that but the compiler says that the ' VisibleClipBounds property is read-only ', and VERY helpful sh*t like that ( sorry for being rude). I've looked everywhere on the web and in the MSDN Library to resolve this problem, but found nothing. I'm getting tired of this! 
So please, O programming gurus, could you help me out? 
Thanks a lot!
Last edited by DarkInnate; Sep 23rd, 2002 at 07:19 PM.
-
Sep 23rd, 2002, 07:18 PM
#2
Thread Starter
New Member
Found solution
Ok, I found the solution to my problem: drawing inside an in-memory bitmap instead of on a form. Because VB .net "seems to have moved away from drawing directly onto controls, and toward drawing to in-memory bitmaps" (see Jeremy Todd's message here). So for those of you who have that problem, here's how to solve it:
1) Create a PictureBox (name it something short, like "pic" or something)
2) In any procedure, type this:
Dim myBitmap as Bitmap = New Bitmap(pic.Width, pic.Height)
Dim g as Graphics = Graphics.FromImage(myBitmap)
3) Draw your stuff (g.drawline(...) or whatever)
4) Assign the drawn bitmap to the PictureBox. Type this:
pic.Image = myBitmap
And there you have it ! You're free to draw stuff as big as you like.
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
|