Click to See Complete Forum and Search --> : Redrawing graphics on background with picture.
Balder
Sep 25th, 2000, 06:16 PM
Hi! I´m working on a program which calculates and draws 3D transformations, rotating cubes and other shapes. This means I redraw the graphic often. With a black background thats allright, I draw the "old" graphics i black before drawing "new" graphics in the specific color. The problem is that I want to use a picture as background. How do I erase old graphics without destroying the background? I've tried .Refresh but it doesn't seem fast enough. What kind of object is best to use, Image, PictureBox, Form ?
Please write if you know a solution, thanks!!
Hi.
I have faced the exact same problem not long ago. I have a solution.
You must use 2 pictureboxes, one visible, one not. The "Official" image must be drawn on the invisile picturebox (set autoredraw at True). When one of the object is modified (moved, resized, etc...) instead of drawing a black object and redrawing modifications, which erases the background as the object is being modified, use the BitBLT API to copy the content of the invisible picturebox into the visible picturebox EVERYTIME THERE IS A MODIFICATION (See http://www.vbapi.com for more info on Bitblt and examples).
That means if you wish to stretch (for example) an object, you must:
- Delete the object from the invisible picturbox
- clear the visible picturebox (.cls)
- use bitblt to copy the invisible into the visible
- draw your modified object on the visible picturebox (set autoredraw at false)
This operation must be done every time there is the slightest modification to your object (that means if you stretch using the mouse, you must call this procedure with the Mousemove event).
When the object is finished being modified, draw it on the "offical" picturebox, the invisible one.
And the job is done!
I hope this is clear enough...
Good luck!
I made a small mistake: Dont clear the image, it flikers too much. But you don't have to do it anyway, the bitblt function will overwrite whatever is drawn on the picturebox anyway.
Balder
Sep 25th, 2000, 07:26 PM
Thank you Alain!
This is the first time I visit this page and it seem great.
I hope I can help you out some day.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.