Без темы
<<  Japans Outward FDI in Globalization JavaSpacesTM  >>
Java Multimedia: Images, Animation, Audio and Video
Java Multimedia: Images, Animation, Audio and Video
30
30
30
30
30
30
30
30
30
30
Image Example 1. import 1.1 Declare objects 2. init() 2.1 Initialize
Image Example 1. import 1.1 Declare objects 2. init() 2.1 Initialize
3.2 paintIcon call Program Output
3.2 paintIcon call Program Output
30
30
30
30
1. import 1.1 Declare objects 2. init 2.1 Set layout
1. import 1.1 Declare objects 2. init 2.1 Set layout
2.2 Add buttons 2.3 Initialize audio clips 3. stop 4. Class
2.2 Add buttons 2.3 Initialize audio clips 3. stop 4. Class
Program Output
Program Output
30
30
30
30
30
30
1. import 1.1 implements ActionListener 1.2 Declare objects 1.3
1. import 1.1 implements ActionListener 1.2 Declare objects 1.3
2.2 If image loaded, display it (paintIcon) 2.3 Increment currentImage
2.2 If image loaded, display it (paintIcon) 2.3 Increment currentImage
3.4. getPreferredSize 4. main
3.4. getPreferredSize 4. main
Program Output
Program Output
30
30
30
30
30
30
30
30
1. import 1.1 LogoAnimator class as before 1.2 Constructor to allow
1. import 1.1 LogoAnimator class as before 1.2 Constructor to allow
2. Methods as before
2. Methods as before
2. Methods as before
2. Methods as before
Java Multimedia: Images, Animation, Audio and Video
Java Multimedia: Images, Animation, Audio and Video
Applet 1. init 1.1 Initialize objects from parameters 1.2 Supply
Applet 1. init 1.1 Initialize objects from parameters 1.2 Supply
3. startAnimation
3. startAnimation
30
30
1. import 1.1 Declare objects 2. init 2.1 addMouseListener 2.2
1. import 1.1 Declare objects 2. init 2.1 addMouseListener 2.2
3. paint 4. translateLocation 4.1 Display message depending on x
3. paint 4. translateLocation 4.1 Display message depending on x
Program Output
Program Output
30
30
30
30
30
30

Презентация на тему: «Java Multimedia: Images, Animation, Audio and Video». Автор: kalid. Файл: «Java Multimedia: Images, Animation, Audio and Video.ppt». Размер zip-архива: 188 КБ.

Java Multimedia: Images, Animation, Audio and Video

содержание презентации «Java Multimedia: Images, Animation, Audio and Video.ppt»
СлайдТекст
1 Java Multimedia: Images, Animation, Audio and Video

Java Multimedia: Images, Animation, Audio and Video

Outline 30.1 Introduction 30.2 Loading, Displaying and Scaling Images 30.3 Loading and Playing Audio Clips 30.4 Animating a Series of Images 30.5 Animation Issues 30.6 Customizing Applets via the HTML param Tag 30.7 Image Maps 30.8 Java Plug-In 30.9 Internet and World Wide Web Resources

2 30

30

1 Introduction

Revolution in computer industry Before, computers used for high-speed calculations Now, data manipulation important Multimedia "sizzle" of Java - images, sound, video CDs, DVDs, video cards Demands extraordinary computing power Fast processors making multimedia possible Java Has built-in multimedia capabilities Most programming languages do not Develop powerful multimedia applications

3 30

30

2 Loading, Displaying and Scaling Images

Java Multimedia Graphics, images, animations, sounds, and video Begin with images Class Image (java.awt) Abstract class, cannot create an object directly Must request that an Image be loaded and returned to you Class Applet (superclass of JApplet) has this method getImage( imageLocation, filename ); imageLocation - getDocumentBase() - URL (address) of HTML file filename - Java supports .gif and .jpg (.jpeg)

4 30

30

2 Loading, Displaying and Scaling Images (II)

Displaying Images with drawImage Many overloaded versions g.drawImage( myImage, x, y, ImageObserver ); myImage - Image object x,y - coordinates to display image ImageObserver - object on which image is displayed Use "this" to indicate the applet Can be any object that implements ImageObserver interface g.drawImage( myImage, x, y, width, height, ImageObserver ); width and height - dimensions of image (automatically scaled) getWidth(), getHeight() - return dimensions of applet

5 30

30

2 Loading, Displaying and Scaling Images (III)

Class ImageIcon Not an abstract class (can create objects) Example constructor private ImageIcon myIcon; myIcon = new ImageIcon( "myIcon.gif" ); Displaying Icons with method paintIcon myIcon.paintIcon( Component, Graphics, x, y ) Component - Component object on which to display image (this) Graphics - Graphics object used to render image (g) x, y - coordinates of Icon

6 30

30

2 Loading, Displaying and Scaling Images (IV)

Usage ImageIcons are simpler than Images Create objects directly No need for ImageObserver reference However, cannot scale ImageIcons Scaling Use ImageIcon method getImage Returns Image reference This can be used with drawImage and be scaled

7 Image Example 1. import 1.1 Declare objects 2. init() 2.1 Initialize

Image Example 1. import 1.1 Declare objects 2. init() 2.1 Initialize

objects 3. paint() 3.1 drawImage calls

8 3.2 paintIcon call Program Output

3.2 paintIcon call Program Output

9 30

30

3 Loading and Playing Audio Clips

Audio clips Require speakers and a sound board Sound engine - plays audio clips Supports .au, .wav, .aif, .mid Java Media Framework supports additional formats Playing audio clips play method in Applet Plays clip once, marked for garbage collection when finished play( location, soundFileName ); location - getDocumentBase (URL of HTML file) play( soundURL ); soundURL - URL that contains location and filename of clip

10 30

30

3 Loading and Playing Audio Clips (II)

Playing audio clips Method play from AudioClip interface More flexible than Applet method play Audio stored in program, can be reused getAudioClip Returns reference to an AudioClip Same format as Applet method play getAudioClip( location, filename ) getAudioClip( soundURL ) Once AudioClip loaded, use methods play - plays audio once loop - continuous loops audio in background stop - terminates clip that is currently playing

11 1. import 1.1 Declare objects 2. init 2.1 Set layout

1. import 1.1 Declare objects 2. init 2.1 Set layout

12 2.2 Add buttons 2.3 Initialize audio clips 3. stop 4. Class

2.2 Add buttons 2.3 Initialize audio clips 3. stop 4. Class

ButtonHandler

13 Program Output

Program Output

14 30

30

4 Animating a Series of Images

Following example Use a series of images stored in an array Use same techniques to load and display ImageIcons Class Timer Generates ActionEvents at a fixed interval in milliseconds Timer ( animationDelay, ActionListener ); ActionListener - ActionListener that will respond to ActionEvents Methods start stop restart isRunning

15 30

30

4 Animating a Series of Images (II)

Method repaint Calls update, which calls paintComponent Subclasses of JComponent should draw in method paintComponent Call superclass's paintComponent to make sure Swing components displayed properly View area Width and height specify entire window, not client area Dimension objects Contain width and height values myDimObject = new Dimension( 100, 200 ); myDimObject.width

16 30

30

4 Animating a Series of Images (III)

getImageLoadStatus ImageIcon method Determines if image is completely loaded into memory Only complete images should be displayed (smooth animation) If loaded, returns MediaTracker.COMPLETE MediaTracker Can determine when images are loaded, or force program to wait if not ImageIcon creates our MediaTracker for us

17 1. import 1.1 implements ActionListener 1.2 Declare objects 1.3

1. import 1.1 implements ActionListener 1.2 Declare objects 1.3

Constructor 1.4 Initialize ImageIcon array 2. paintComponent 2.1 Call to superclass paintComponent

18 2.2 If image loaded, display it (paintIcon) 2.3 Increment currentImage

2.2 If image loaded, display it (paintIcon) 2.3 Increment currentImage

3. actionPerformed 3.1 startAnimation 3.2 stopAnimation 3.3 getMinimumSize

19 3.4. getPreferredSize 4. main

3.4. getPreferredSize 4. main

20 Program Output

Program Output

21 30

30

5 Animation Issues

Storing images Interlaced/non-interlaced formats Specifies order in which pixels are stored Non-interlaced - pixels stored in order they appear on screen Image appears in chunks from top to bottom as it is loaded Interlaced - pixels stored in rows, but out of order Image appears to fade in and become more clear Animation flickers Due to update being called in response to repaint In AWT GUI components Draws filled rectangle in background color where image was Draw image, sleep, clear background (flicker), draw next image... Swing's JPanel overrides update to avoid this

22 30

30

5 Animation Issues (II)

Double buffering Used to smooth animations Program renders one image on screen Builds next image in off-screen buffer When time to display next image, done smoothly Partial images user would have seen (while image loads) are hidden All pixels for next image displayed at once Space/Time tradeoff Reduces flicker, but can slow animation speed and uses more memory Used by Swing GUI components by default

23 30

30

6 Customizing Applets via the HTML param Tag

Applets Customize through parameters in HTML file that invokes it <html> <applet code="LogoApplet.class" width=400 height=400> <param name="totalimages" value="30"> <param name="imagename" value="deitel"> <param name="animationdelay" value="200"> </applet> </html> Invokes applet LogoApplet param tags Each has a name and a value Use Applet method getParameter (returns a String) parameter = getParameter( "animationdelay" );

24 30

30

6 Customizing Applets via the HTML param Tag (II)

Following example Use the LogoAnimator class as before, but modified slightly Create Applet LogoApplet Takes parameters Creates LogoAnimator object using the parameters Plays animation

25 1. import 1.1 LogoAnimator class as before 1.2 Constructor to allow

1. import 1.1 LogoAnimator class as before 1.2 Constructor to allow

customization

26 2. Methods as before

2. Methods as before

27 2. Methods as before

2. Methods as before

28 Java Multimedia: Images, Animation, Audio and Video
29 Applet 1. init 1.1 Initialize objects from parameters 1.2 Supply

Applet 1. init 1.1 Initialize objects from parameters 1.2 Supply

variables to constructor 2. Set layout

30 3. startAnimation

3. startAnimation

31 30

30

7 Image Maps

Image map Image that has hot areas User can click to accomplish a task Bubble help When mouse over particular point in screen, small message displayed in status bar In the following example Load several images Use event handler mouseMoved to find x-coordinate Based on the x-coordinate, display a message

32 1. import 1.1 Declare objects 2. init 2.1 addMouseListener 2.2

1. import 1.1 Declare objects 2. init 2.1 addMouseListener 2.2

Initialize ImageIcon

33 3. paint 4. translateLocation 4.1 Display message depending on x

3. paint 4. translateLocation 4.1 Display message depending on x

34 Program Output

Program Output

35 30

30

8 Java Plug-In

Web browsers Many different browser versions Most support Java 1.0 and 1.1, but few support Java 2 Inconsistent support of 1.1 To use Java 2 in an applet, use the Java Plug-in Bypasses browser's Java support Installs complete version of Java Runtime Environment on user's computer Large file - ideal for corporate intranets and high-speed networks

36 30

30

8 Java Plug-In (II)

Using the Plug in with applets The <applet>, <param> and </applet> tags must be converted Must indicate that Plug-in should be used to execute applet Java Plug-in 1.2 HTML Converter Performs conversion for us http://java.sun.com/products/plugin/ Execution In install directory type java HTMLConverter Select file to convert and type of conversion

37 30

30

9 Internet and World Wide Web Resources

Internet and web resources for Java Media Framework http://java.sun.com/products/java-media/jmf/ Download and documentation for JMF http://java.sun.com/products/java-media/ jmf/forDevelopers/ Site for javax.media API descriptions Downloadable image, audio, and video galleries Test your multimedia programs http://www.nasa.gov/gallery/index.html http://sunsite.sut.ac.jp/multimed/

«Java Multimedia: Images, Animation, Audio and Video»
http://900igr.net/prezentacija/anglijskij-jazyk/java-multimedia-images-animation-audio-and-video-144623.html
cсылка на страницу
Урок

Английский язык

29 тем
Слайды
900igr.net > Презентации по английскому языку > Без темы > Java Multimedia: Images, Animation, Audio and Video