Results 1 to 16 of 16

Thread: [RESOLVED] SavePicture event using 50% CPU. Any way to reduce that?

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Resolved [RESOLVED] SavePicture event using 50% CPU. Any way to reduce that?

    Hello,

    I am using the following code in a command button.

    VB Code:
    1. SavePicture frmMain.Picture2.Image, "C:\Data\" & Format(Now, "hhmmss") & ".bmp"

    Now when I click the button I watch my CPU and as it is saving the picture to the file it uses about 50% of my CPU. This is saving a picturebox that is about the same size as the screen. When the pic is small it doesn't take much CPU. only when it is a big pic. Is there any way to reduce the quality or somthing to make it not use so much CPU?

    Thank you and have a great evening.
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  2. #2

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Conversation with mind and subconscious.

    Mind: Arrrgg no one replied!

    Mind: Maybe it was too late at night when I posted?

    Subconscious: Yea maybe so but oh well get over it, someone may still respond.

    Mind: Hmm maybe but I think I will post a new post in the thread to bump me to the top of the list so someone will see my post..

    Subconscious: NO, don't you dare! Thats cheating!

    Mind: So what no one will respond if I don't!

    Subconscious: Isn't it better to suffer then cheat?
    Subconscious: Don't push that button!
    Subconscious: I'm warning you! Don't push that button!
    Subconscious: NO WAIT! NO NO NO NO!!!! AHHHHHHHHHHHHHH!!!!!!


    Stilekid007: Wow that was stupid.
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  3. #3
    Hyperactive Member Frodo_Baggins's Avatar
    Join Date
    Feb 2004
    Location
    Sao Paulo, Brazil
    Posts
    397

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Argh... Try making your own function for saving pictures
    Once I tried making one... it's not actually that hard... search the web for a save-to-bmp function... then maybe you can control it better, perhaps adding a doevents in the midst of it.
    Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.

  4. #4

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Hmm, Ok, I will see what I can do. I already had a doevents in the code riht above the savepicture function.

    But thanks for your reply!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    What is wrong with the 50% cpu usage?

    Is it causing other apps to not run at all?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Yea it makes the computer slow for about 2 seconds everytime it saves an image making everything else skip.
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    50% CPU is not a bad thing - seems that it is that during that 2 seconds, it is such an intensive operation, that you would prefer it to run slower and yield easier to other apps...

    Sounds like the only thing you could do is write you own routine to save the picture and perform a DOEVENTS every so often in the loop.
    Last edited by szlamany; Jul 8th, 2005 at 07:58 PM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Saving a large file like that with the 1-2 second pause is normal. It's the same in the DirectX made applications when you press a key to take a snapshot of the entire window it's in.

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Quote Originally Posted by stilekid007
    ... I already had a doevents in the code riht above the savepicture function. ...
    That's what causing your CPU to go crazy for a little while, though ...

  10. #10

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Ok, so its not anything I really need to worry about it? I don't think it would hurt much anyway. The program runs 24/7 so I was hoping there would be a way to lower that CPU usage but the savepicture event won't be very often. So I think I am good. I was just wondering if there was anything out there that was easy and known...

    So thank you all for your replys.

    You all are great!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  11. #11

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Quote Originally Posted by RhinoBull
    That's what causing your CPU to go crazy for a little while, though ...
    Yea I see if I take the DOevents out it lowers it a tad - but just a tad.

    :P

    Thanks man!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  12. #12
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    DoEvents is considered the worse VB function ever written. There are many discussions in VBForums on it.

    I even have a thread in the code bank that gives you alternatives

    http://www.vbforums.com/showthread.php?t=315416

  13. #13

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Quote Originally Posted by Jacob Roman
    DoEvents is considered the worse VB function ever written. There are many discussions in VBForums on it.

    I even have a thread in the code bank that gives you alternatives

    http://www.vbforums.com/showthread.php?t=315416
    Well, that is a very good thread. For someone like me who knows nothing about DoEvents.
    Thank you sir!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  14. #14
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Quote Originally Posted by stilekid007
    Yea I see if I take the DOevents out it lowers it a tad - but just a tad.

    :P

    Thanks man!
    Stilekid007
    That's just a high level of it (DoEvents) ...

  15. #15
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Quote Originally Posted by Jacob Roman
    DoEvents is considered the worse VB function ever written. ...
    I will agree on this one more time ...

  16. #16

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: SavePicture event using 50% CPU. Any way to reduce that?

    Ok, well that concludes this thread hehe :P

    Thank you all!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

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