forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserveImageLoad.java
More file actions
35 lines (31 loc) · 1 KB
/
Copy pathObserveImageLoad.java
File metadata and controls
35 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//file: ObserveImageLoad.java
import java.awt.*;
import java.awt.image.*;
public class ObserveImageLoad {
public static void main( String [] args)
{
ImageObserver myObserver = new ImageObserver() {
public boolean imageUpdate(
Image image, int flags, int x, int y, int width, int height)
{
if ( (flags & HEIGHT) !=0 )
System.out.println("Image height = " + height );
if ( (flags & WIDTH ) !=0 )
System.out.println("Image width = " + width );
if ( (flags & FRAMEBITS) != 0 )
System.out.println("Another frame finished.");
if ( (flags & SOMEBITS) != 0 )
System.out.println("Image section :"
+ new Rectangle( x, y, width, height ) );
if ( (flags & ALLBITS) != 0 )
System.out.println("Image finished!");
if ( (flags & ABORT) != 0 )
System.out.println("Image load aborted...");
return true;
}
};
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image img = toolkit.getImage( args[0] );
toolkit.prepareImage( img, -1, -1, myObserver );
}
}