|
-
Jul 7th, 2005, 10:13 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] SavePicture event using 50% CPU. Any way to reduce that?
Hello,
I am using the following code in a command button.
VB Code:
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
 Originally Posted by stilekid007
-
Jul 8th, 2005, 10:05 AM
#2
Thread Starter
Hyperactive Member
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.
 Originally Posted by stilekid007
-
Jul 8th, 2005, 10:36 AM
#3
Hyperactive Member
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.
-
Jul 8th, 2005, 02:54 PM
#4
Thread Starter
Hyperactive Member
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
 Originally Posted by stilekid007
-
Jul 8th, 2005, 02:56 PM
#5
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?
-
Jul 8th, 2005, 04:30 PM
#6
Thread Starter
Hyperactive Member
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.
 Originally Posted by stilekid007
-
Jul 8th, 2005, 04:34 PM
#7
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.
-
Jul 8th, 2005, 07:56 PM
#8
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.
-
Jul 8th, 2005, 07:59 PM
#9
Re: SavePicture event using 50% CPU. Any way to reduce that?
 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 ...
-
Jul 8th, 2005, 08:01 PM
#10
Thread Starter
Hyperactive Member
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
 Originally Posted by stilekid007
-
Jul 8th, 2005, 08:04 PM
#11
Thread Starter
Hyperactive Member
Re: SavePicture event using 50% CPU. Any way to reduce that?
 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
 Originally Posted by stilekid007
-
Jul 8th, 2005, 08:09 PM
#12
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
-
Jul 8th, 2005, 08:13 PM
#13
Thread Starter
Hyperactive Member
Re: SavePicture event using 50% CPU. Any way to reduce that?
 Originally Posted by Jacob Roman
Well, that is a very good thread. For someone like me who knows nothing about DoEvents. 
Thank you sir!
Stilekid007
 Originally Posted by stilekid007
-
Jul 8th, 2005, 08:21 PM
#14
Re: SavePicture event using 50% CPU. Any way to reduce that?
 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) ...
-
Jul 8th, 2005, 08:22 PM
#15
Re: SavePicture event using 50% CPU. Any way to reduce that?
 Originally Posted by Jacob Roman
DoEvents is considered the worse VB function ever written. ...
I will agree on this one more time ...
-
Jul 8th, 2005, 08:28 PM
#16
Thread Starter
Hyperactive Member
Re: SavePicture event using 50% CPU. Any way to reduce that?
Ok, well that concludes this thread hehe :P
Thank you all!
Stilekid007
 Originally Posted by stilekid007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|