这版好像没什么人?
这是从自己程式中撷取一小段的,读取的值就在 ip那个阵列里..
复制程式
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.lang.*;
class pictest{
public static void main(String[] args)throws FileNotFoundException,IOException {
String inStr = JOptionPane.showInputDialog(null,"请输入读取的主档名,或者直接按ENTER离开。");
if (inStr.equals("")){JOptionPane.showMessageDialog(null,"程式结束" );return;}
String inputFile=inStr+".raw";
int ip[][];
int k[] = new int [256]; //0~255色阶
String ipH = JOptionPane.showInputDialog(null,"请输入图档的高");
String ipW = JOptionPane.showInputDialog(null,"请输入图档的宽");
int pH=Integer.parseInt(ipH);
int pW=Integer.parseInt(ipW);
int i,j,ch=pH*pW;
ip=new int [pH][pW];
//OPEN & READ FILE
try{
InputStream is = new FileInputStream(inputFile);
for (i = 0 ; i < pH ; i++ )
for (j = 0 ; j <pW ; j++ )
if ((ch=is.read())!=-1){ip[i][j]=ch;}
is.close();
}catch (IOException e) { JOptionPane.showMessageDialog(null,e); }
}