Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi,

 

I just recently switched over to VB.Net in the midst of my coding a Diablo II-clone, and I have noticed that there is no BitBlt function, so I tried using the GDI DrawImage method.

 

This works fine if I am loading a bitmap from disk into a picturebox, but I cannot then copy a selected rectangle from that picturebox into another picturebox!

 

It says that there is no image in the previous picture box, and so it can't copy the selected portion! Is there something I;m doing wrong or should i use directdraw9 or what?

 

Help requested before I physically burn my copy of VB.NET :)

 

SOloKing

  • *Gurus*
Posted

Anything you draw on a picturebox is essentially temporary. It isn't stored anywhere, it's just displayed on the screen. This is important for performance purposes. If you want to do something like you are trying to do, you need to create an offscreen bitmap. This is easy enough using the Bitmap class. You can get a graphics object from that bitmap using Graphics.FromImage() and draw on it.

 

Once you have drawn on it you are free to assign it to a picturebox if you like, to display it. You do this with the picturebox's Image property. If you want to use DrawImage to draw a portion of your offscreen bitmap to another Graphics object, you can also do so. Several overloads for Graphics.Drawimage allow you to specify a source rectangle to blt from.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • 3 months later...
  • Leaders
Posted
There is also another problem with the Drawimage function as far as games go: it is slower that bitblt. It appears to be just as slow as the VB6 .paintpicture method. You can still use bitblt in VB.net the same way as you do in vb6. The only difference is that you need the GetDC() windows API function to get the handle to the device context for a control, since it is not provided as a property.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...