Results 1 to 4 of 4

Thread: Copying vs assigning Picture/StdPicture object *[RESOLVED]*

  1. #1

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140

    Copying vs assigning Picture/StdPicture object *[RESOLVED]*

    I load a picture in a usercontrol.picture Then I try to copy it in a StdPicture object named picOriginal. I then modify my usercontrol.picture as I want. If I want to get back to my original picture I like to overwrite my usercontrol.picture with the picOriginal object. But it seem that the two objects are modified simultaniously.

    here is a code exemple

    VB Code:
    1. Dim picOriginal As New StdPicture
    2.  
    3. UserControl.Picture = LoadPicture("imgage1.bmp")
    4. Set picOriginal = UserControl.Picture
    5. Set UserControl.Picture = Transform(UserControl.Picture, New_Color, m_TransparentColor)
    6.  
    7. 'Here I see good result
    8. 'Now I want to set it back to Original
    9.  
    10. Set UserControl.Picture = picOriginal
    11. 'Try refresh, repaint...
    12. 'No result
    Last edited by Aldragor; Nov 11th, 2002 at 02:02 PM.
    Mens sana in corpore sano
    ... pour mieux travailler!

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    That's because, instead of copying the picture to the new picture control, VB simply used the same memory space for both pics. In order to get two separate versions of the image (in two separate memory spaces), the image needs to be copied to a new location. Try looking at the BitBlt API I think that will do what you need it to do. And possibly the CopyMem (CopyMemory, I'm not sure of the exact name), but I think BitBlt will suffice.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Thanx

    I will do that, but I'm surprise that is no way to do it in VB!
    Mens sana in corpore sano
    ... pour mieux travailler!

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    It's an object thing..... conserves memory by using pointers instead of physically copying the memory..... can be extremely annoying. Esp, when you mean to copy it to a new location.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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