One way is to use the methods of the BufferedImage class.
Moderator edit: spoonfeeding removed
1. You have already been advised in your own thread that this is not a code factory. We try to help people learn; we don't post reams of code without a word of explanation.
2. BB Code List - Java Programming Forum
edit Moreover, that code -- which doesn't answer the question asked here -- was plagiarized from a blog site, and the terms of license were omitted. Any repeat of such unethical plagiarization without assigning credit to the original author, and/or omitting license terms, may lead to a summary ban. Further warning will not be given before banning.