Ram usage going crazy while using Dim ... as New Bitmap with a timer -


i'm making bot needs detects pixel colors @ few spots every 100ms. way found save current screen bitmap , colors bitmap. seems each 100ms creates new bitmap , don't rid of previous one, increase ram usage !

here code :

 private sub timer1_tick(sender object, e eventargs) handles timer1.tick     dim img new bitmap(1280, 720)     dim imggraphics graphics = graphics.fromimage(img)     imggraphics.copyfromscreen(0, 0, 0, 0, img.size)      dim slot1selec color = img.getpixel(1158, 572)     if slot1selec.toargb = -65906         label2.text = ("1")     else : label2.text = ("0")     end if     dim slot1life color = img.getpixel(1148, 559)     if slot1life.toargb = -13052710         label3.text = ("1")     else : label3.text = ("0")     end if 

and i'm checking 16 pixel colors, here 2 it's same thing after slot2selec, slot2life, slot3selec, slot3life etc...

please ! else other way pixel color without creating stupid bitmaps alot, :)

well found fix !

forgot lines @ end :

    imggraphics.dispose() 

and voila.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -