這版好像沒什麼人?
這是從自己程式中擷取一小段的,讀取的值就在 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); }
}