Jump to content
Xtreme .Net Talk

Should I use DrawImage?


Recommended Posts

Guest Nightmare
Posted

Okay...consider these two pieces of code (mousepointing is a point structure given a value outside of the sub):

 

Private Sub picPart_QueryContinueDrag(ByVal sender As _
Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs)
   dim newlocation as point
       
   newlocation = Me.PointToClient(MousePosition)
   newlocation.X -= mousepointing.X
   newlocation.Y -= mousepointing.Y    
       
   sender.location = newlocation
end sub

AND

Private Sub picPart_QueryContinueDrag(ByVal sender As _
Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs)
   dim newlocation as point

   newlocation = Me.PointToClient(MousePosition)
   newlocation.X -= mousepointing.X
   newlocation.Y -= mousepointing.Y

   CreateGraphics.Clear(Me.BackColor)
   Dim gr As Graphics
   gr = Me.CreateGraphics
   gr.DrawImage(sender.image, newlocation)
end sub

 

The point of either of these functions is so that I can drag an image around a form with it appearing under the cursor as it is being dragged. Using DrawImage, after I am done dragging I obviously would need to move the picturebox to that location.

 

As I understand it DrawImage is .NET's equivalent to BitBlt without an API call. However, moving the control around the form with the mouse causes virtually no flicker whereas using DrawImage does (for me anyway).

 

So which one is more efficient, less memory draining...and which one would you recommend using? Or is there a better method...I'm no expert on this stuff...

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...