Solved

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

Posted on 2004-10-06
3
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

707 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