Solved

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

Posted on 2004-10-06
3
299 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

786 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