Results 1 to 14 of 14

Thread: Corruption in Image Control

  1. #1

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116
    My program loads picture files into an image control from a specific directory every 2 seconds. Once it reach the end, it cycle to the beginning and reload the first pictures in again. After several cycles, it just crash and load a white image into the image control. Anyone experience with this before?
    License to Program

    007

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    You must clear the image control picture before you loading a new image into it. if you did not do that, it take all you memory and cause your program having insufficient memory error.

    Code:
    Image1.Picture = LoadPicture()   
    Image1.Picture = LoadPicture(<Your Image file>)

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    BTW, you should load all images, if you don't have a too large amount of them, into stdpictures and then you just switch the pictures every 2 seconds.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116
    Thanks you Chris and Ked.


    Ked I like to know what you mean by "into stdpictures"


    I am making a screen saver loading against a particular directory. What you said make sense Chris. I thought of that but wasn't sure if that was the problem. Now you confirmed. Thanks.
    License to Program

    007

  5. #5
    Guest
    StdPicture is a data type. (a picture). You can treat it the same way you would treat the "Picture" property of a PictureBox.
    Code:
    Dim MyPic As StdPicture
    
    MyPic = LoadPicture("MyFileName.bmp")
    Then you can load it into the Picturebox by using:
    Code:
    Picture1 = MyPic

  6. #6

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116
    Thank you for your explantion Meg. Have a good weekend all.
    License to Program

    007

  7. #7

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116

    Which one should I use for my screen saver?

    Code:
      Dim Temp As New StdPicture
      'Set Temp = LoadPicture()
      Set Temp = LoadPicture(File)
      Set Image1.Picture = Temp
    Code:
      Dim Temp As New StdPicture
      Set Temp = LoadPicture()
      Set Temp = LoadPicture(File)
      Set Image1.Picture = Temp
    License to Program

    007

  8. #8
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    I am not sure about this but here is an idea.

    You can also set = nothing.


    SET Image1.Picture = Nothing
    SET Image1.Picture = LoadPicture(Your File)
    Chemically Formulated As:
    Dr. Nitro

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well actually it's not nessesary, the vb unloads the stdpicture automatically if you switch to another, otherways vb would be a bit crappy language.

    Btw, 0 0 7, i thought you had an animation of pictures ?

    You could have use of an array of stdpictures, of which you just switch to the image control, for instance in a timer:
    Code:
    private buffer() as stdpicture
    private counter as integer, count as integer
    
    Private Sub Form_Load()
    Dim x as long
        count=10
        for x = 0 to 9
           Set buffer(X) = LoadPicture(File & x & ".bmp")
        next x
    End Sub
    
    Private Sub Timer1_Timer()
        counter=(counter + 1)mod count
        set image1.picture = buffer(counter)
    End Sub
    And theres one more thing, don't use new keyword in a declaration statement
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116
    Thanks Kedaman,

    If I store all 200 Jpegs in a directory into the array buffer(X), wouldn't that take up alot of memory?
    License to Program

    007

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Whoops, that would be almost too much, unless they are small like 50*50 or something. If not you could skip the buffer thing, and just load the pictures with Loadpicture directly into the image.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116
    If I do that, I am back to square 1. I would get a freeze screen after the 400th picture. I am going to try either Chris or Nitro code. Setting it back to nothing before I load a new file into the image control. I think Chris is right, it was hogging up memory or resources.

    Thanks for your help Kedaman!
    License to Program

    007

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm out of ideas, well try Nitros and Chris stuff, but i'm sure the problem lays somewhere else
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14

    Thread Starter
    Lively Member James Bond 007's Avatar
    Join Date
    May 2000
    Location
    London
    Posts
    116

    Talking

    Thank you for your time. You did all you can. Wish I can pay you in some way. Bye.
    License to Program

    007

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