Next: 4.2 ヒストグラム作成
Up: 4 画像の入出力
Previous: 4 画像の入出力
画像ファイルを読み込む例としてImageLoadクラスを示す.
画像の表示には,java.awt.Graphicsクラスのメソッドである
drawImageメソッドを用いる.
// ImageLoad.java
/*
<applet code="ImageLoad.class"
width=1000 height =800>
</applet>
*/
import java.applet.Applet;
import java.awt.*;
public class ImageLoad extends Applet {
Image image;
public void init(){
image = getImage(getDocumentBase(),
"aiboakira.jpg");
}
public void paint(Graphics g){
g.drawImage(image, 0, 0, this);
}
}
ImageLoad.classをappletとして取り込む
htmlファイルは次のようになる.
<html>
<head><title>ImageLoad Applet</title>
<applet code="ImageLoad.class" width=1000 height =800>
</applet>
<hr>
<A HREF="ImageLoad.java">source</a>
</body>
</html>
generated through LaTeX2HTML. M.Inaba 平成18年5月7日