Sorry, I don't know code. There are a few apps that will do screenshots on the BlackBerry. I think that would be a lot easier than what you're trying to do.
JL_Cmder is one -- can be found on forum search.
http://www.blackberryforums.com/afte...n-capture.html
I think there's another one, but I can't remember for sure.