Results 1 to 4 of 4

Thread: Redrawing graphics on background with picture.

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    37

    Question

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

  2. #2
    Guest
    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!

  3. #3
    Guest
    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    37

    Wink

    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.
    Balder = Viking God
    VB6/VC++ Enterprise Editions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width