Solved

Picture1.Picture = Picture2.image, which resources are used ?

Posted on 2004-10-06
3
297 Views
Last Modified: 2012-05-05
Hi iam doing the above to illustrate a grid and a rectangle moving with the mouse over this, this means

I generate a picture and put it into Picture2 and picture1, on a mousemove on picture 1 i draw a hollow rectangle which corresponds to the position of the mouse over the image, next the user triggers yet another mouse move i do the command
Picture1.Picture = Picture2.image to restore the original image (deleting the rectangle) and then draw the new rectangle onto Picture1, is this the best method to visualize a rectangle moving with the mouse, the thing is that this solution lags on some computers.

Which resources are used when you perform a Picture1.Picture = Picture2.image, is it only processor or does the GFX card have alot to do with it ?

Does someone have another idea of how this could be done ?
0
Comment
Question by:mSchmidt
3 Comments
 
LVL 3

Expert Comment

by:redfordb
ID: 12237231
Instead of copying the image from picture2 to picture1, just use the cls method of the picturebox to remove the hollowbox
ie replace Picture1.Picture = Picture2.image with Picture1.cls

This should improve the speed at which this happens.
Please advise if it does help.
0
 
LVL 1

Expert Comment

by:souvey
ID: 12254934
I think it would be more efficiant to not draw a rectangle at all...
Have invisible picture boxes with an image in them that has the rectangle already on the image
Then just switch using them

It shouldn't use any resources to set the picture (not many at least)
I think you should try not using the drawing functions instead...
Please reply is this is what you meant
0
 
LVL 6

Accepted Solution

by:
SCDMETA earned 500 total points
ID: 12256245
Picture boxes have two drawing surfaces: Picture and Image.  For example, you can set the Picture surface to a JPG.  Then draw lines, circles etc on top of it.  If you perform a Picture1.cls, it clears the drawing but not the JPG.

In your case, you could draw your grid.  Then, set the Picture1.Picture = Picture1.image.  This saves the grid.  Now when the mouse moves draw your rectangle.  To restore the clean grid before drawing the "moved" rectangle, perform a Picture1.cls.

See here for more details: http://www.vb-helper.com/howto_erase_picture_lines.html

On other option is to save and restore just the touched portion of the picture.  There is a windows API called BitBlt that can restore just a small rectangle of an image. Try this link: http://www.vbgamer.com/tutorial.asp?ndx=20

Good Luck

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now