Images
We complete this section on animation with a brief study of the alternative approach to creating moving images on screen - that of displaying preformed images at a suitable speed. Java has a very rich collection of classes and methods to achieve this task. The main class is the Image class. For example:
private Image picture = null;
An image can then be assigned to variable picture from a file in GIF, JPEG or PNG
format. Images can also be accessed using a URL:
picture = getToolKit( ).getImage("mypicture.gif");
This would assign the image mypicture.gif to variable picture. An image is then displayed using drawImage within a paint method:
g.drawImage(picture, 0, 0, this);
There are several drawImage methods in the Graphics class. The above example takes as its arguments an Image, the x- and y-coordinates to draw at and an ImageObserver. In this case, the ImageObserver is the main class itself and it is simply acting as somewhere to receive notifications about Image information as the Image is constructed. This is denoted by the use of the Java keyword this.
Using these basic classes and methods, typically many images would be loaded into an array or vector. These would then be displayed with a suitable 'sleep' period to allow the images to be drawn and to fool the eye into seeing a moving image rather than a slide show of individual images.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Images homework and assignments? Live Images experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Images homework help, java assignment help and Images projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours