473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

System resource hog

I am using a timer to capture the screen, and verify certain criteria
through GetPixel(). The timer is set at 333 (about one third of a second).
And after running the program, it takes MASSIVE resources and slows the
computer down. Is there something I can do to prevent this? Here is the code
I am using:

I am using a program to capture the screen, and saving it in an image box;

'Capture Screen

CaptureScreen()

ScreenPictureBox.Image = oBackground

Then saving the image to a bitmap;

'Save save image to bitmap

Dim B As New Bitmap(ScreenPictureBox.Image)

I then GetPixel to determine certain procedures;

'Clock

RGB = B.GetPixel(967, 512)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=8, G=8, B=8" Then

ActionLabel.Text = "Clock"

End If

'Player 1

RGB = B.GetPixel(818, 123)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=0, G=0, B=0" Then

Label18.Text = "Player 1"

End If

.. . .
Jul 4 '06 #1
4 1380
So you capture the entire screen, put the bitmap in a PictureBox, then
copy the bitmap into a new bitmap?

Why don't you just capture the part of the screen that you are
interrested in?

Daniel N wrote:
I am using a timer to capture the screen, and verify certain criteria
through GetPixel(). The timer is set at 333 (about one third of a second).
And after running the program, it takes MASSIVE resources and slows the
computer down. Is there something I can do to prevent this? Here is the code
I am using:

I am using a program to capture the screen, and saving it in an image box;

'Capture Screen

CaptureScreen()

ScreenPictureBox.Image = oBackground

Then saving the image to a bitmap;

'Save save image to bitmap

Dim B As New Bitmap(ScreenPictureBox.Image)

I then GetPixel to determine certain procedures;

'Clock

RGB = B.GetPixel(967, 512)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=8, G=8, B=8" Then

ActionLabel.Text = "Clock"

End If

'Player 1

RGB = B.GetPixel(818, 123)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=0, G=0, B=0" Then

Label18.Text = "Player 1"

End If

. . .

Jul 5 '06 #2
Daniel,

I have no idea what the problem is, but why do you convert the color to a
string and the compare strings if you could check the properties of the
colors like this:

Dim bm As Bitmap = Me.BackgroundImage
Dim col As Color = bm.GetPixel(100, 100)
If col.A = 255 AndAlso col.B = 8 AndAlso col.G = 8 AndAlso col.R = 8
Then
' do something
End If

Also, when working with disposable object, like bitmap objects, make sure
that you do not forget to dispĂ´se them if you do not need them anymore. Like
this:

Dim bm As Bitmap = Me.BackgroundImage
Try
' do something with the bitmap
Finally
bm.Dispose()
End

Also, you could (but is not recommended) start a garbage collection after
you finish your resource comsuming operations with GC.Collect. However the
garbage collector ususally runs automaticaaly when resources are needed, so
ususally this is not necessary.

Hope this helps,

Joris

"Daniel N" wrote:
I am using a timer to capture the screen, and verify certain criteria
through GetPixel(). The timer is set at 333 (about one third of a second).
And after running the program, it takes MASSIVE resources and slows the
computer down. Is there something I can do to prevent this? Here is the code
I am using:

I am using a program to capture the screen, and saving it in an image box;

'Capture Screen

CaptureScreen()

ScreenPictureBox.Image = oBackground

Then saving the image to a bitmap;

'Save save image to bitmap

Dim B As New Bitmap(ScreenPictureBox.Image)

I then GetPixel to determine certain procedures;

'Clock

RGB = B.GetPixel(967, 512)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=8, G=8, B=8" Then

ActionLabel.Text = "Clock"

End If

'Player 1

RGB = B.GetPixel(818, 123)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=0, G=0, B=0" Then

Label18.Text = "Player 1"

End If

.. . .
Jul 5 '06 #3
Hm... Running a garbage collection three times a second, that should
quite efficiently kill performance. ;)

Joris Zwaenepoel wrote:
Daniel,

I have no idea what the problem is, but why do you convert the color to a
string and the compare strings if you could check the properties of the
colors like this:

Dim bm As Bitmap = Me.BackgroundImage
Dim col As Color = bm.GetPixel(100, 100)
If col.A = 255 AndAlso col.B = 8 AndAlso col.G = 8 AndAlso col.R = 8
Then
' do something
End If

Also, when working with disposable object, like bitmap objects, make sure
that you do not forget to dispĂ´se them if you do not need them anymore. Like
this:

Dim bm As Bitmap = Me.BackgroundImage
Try
' do something with the bitmap
Finally
bm.Dispose()
End

Also, you could (but is not recommended) start a garbage collection after
you finish your resource comsuming operations with GC.Collect. However the
garbage collector ususally runs automaticaaly when resources are needed, so
ususally this is not necessary.

Hope this helps,

Joris

"Daniel N" wrote:
>I am using a timer to capture the screen, and verify certain criteria
through GetPixel(). The timer is set at 333 (about one third of a second).
And after running the program, it takes MASSIVE resources and slows the
computer down. Is there something I can do to prevent this? Here is the code
I am using:

I am using a program to capture the screen, and saving it in an image box;

'Capture Screen

CaptureScreen()

ScreenPictureBox.Image = oBackground

Then saving the image to a bitmap;

'Save save image to bitmap

Dim B As New Bitmap(ScreenPictureBox.Image)

I then GetPixel to determine certain procedures;

'Clock

RGB = B.GetPixel(967, 512)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=8, G=8, B=8" Then

ActionLabel.Text = "Clock"

End If

'Player 1

RGB = B.GetPixel(818, 123)

str = RGB.ToString

str = str.Substring(7, str.Length - 8)

If str = "A=255, R=0, G=0, B=0" Then

Label18.Text = "Player 1"

End If

.. . .
Jul 5 '06 #4
The suggestions helped TREMENDOUSLY. Thanks.
Jul 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: avishosh | last post by:
Hi, I'm getting the folowing error when tring to open xml file: -------------------------------------------------------------------------------- The system cannot locate the resource specified....
0
by: Roz Lee | last post by:
I am trying to access a satellite assembly for a custom culture using Resource Manager. When I use the .getstring method I get the following error message: System.ArgumentException: I can't...
7
by: WALDO | last post by:
I have an interesting quandary. I have developed a program in VB.Net to extract an icon resource from an exe/dll or from an ico file and enumerate its formats (16x16,256 color;32x32,true...
2
by: mark | r | last post by:
Microsoft JET Database Engine error '80004005' System resource exceeded. /webutils/include_webstats_weeklycount.asp, line 23 Anyone know what this means and how to fix it. Mark
3
by: Jesse | last post by:
Hi together, I've a problem with compiling an application with a build-Script and run it after. Several resource-files I compile with resgen.exe and put the files into a folders of the...
2
by: dpomt | last post by:
I am using the ContentTemplate to extend the CreateUserWizard's CreateUserWizardStep with additional controls. For the CreateUserWizardStep labels, I would like to keep the automatic localization....
1
by: Om | last post by:
Hi All, Can anyone explain me, why we have Resource and Distribution System Database in SQL Server 2005. Whether they were also available in previous versions also. Thanks in Advance. ...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
4
by: JamTech | last post by:
The Script Resource and the Web Resource files are generating intermittent errors in my application. I have been trying to chase the cause of the problem but to no avail. I notice that the “d”...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.