?? show.java
字號(hào):
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
public class show {
public static void main(String[] args) {
new show().init(args);
}
BufferedImage bi;
public void init(String[] args) {
try {
String name = args[0];
int width = Integer.parseInt(args[1]);
File f = new File(name);
int size = (int)f.length();
byte[] bb = new byte[size];
FileInputStream is = new FileInputStream(f);
is.read(bb);
is.close();
int height = size*8/width;
int w = width/8;
bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int a = (i*w)+j/8;
int b = j%8;
if ((bb[a] & (1<<(7-b))) != 0) {
bi.setRGB(j, i, 0);
} else {
bi.setRGB(j, i, 0x00ffc742);
}
}
}
Frame frame = new Frame(name+" - Show Binary Pics");
Canvas canvas = new ACanvas();
canvas.setSize(width, height);
frame.setLayout(new BorderLayout());
frame.add(canvas, BorderLayout.CENTER);
frame.setSize(width+4, height+40);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
System.out.println(args[0]+" - ("+width+" * "+height+")");
frame.show();
} catch (Exception ex) {
ex.printStackTrace();
}
}
class ACanvas extends Canvas {
public void paint(Graphics g) {
g.drawImage(bi, 0, 0, this);
}
public void update(Graphics g) {
return;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -