⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.java

📁 一个JAVA的扫雷游戏源代码
💻 JAVA
字号:
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;
        }
    }
        
}        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -