H
hussainak
Hi, i ve got a raw image to be displayed, i ve used the program below
to generate the raw image...
to generate the raw image...
Code:
import javax.swing.*;
import java.io.*;
public class Rawtest{
public Rawtest(){
int array[];
RandomAccessFile newfile;
array = new int[256];
try{
newfile = new RandomAccessFile("c:\\grey.raw", "rw");
newfile.seek(newfile.length());
for(int i=0; i<array.length; i++)
{
array[i] = i;
//System.out.println(array[i]);
for(int j=0; j<256; j++)
newfile.writeByte(array[i]);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e,"Exception
Raised",JOptionPane.INFORMATION_MESSAGE);
}
}
public static void main(String args[]){
new Rawtest();
}
}
To display this image i m using this program..........
[CODE]
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.image.*;
public class RawDisp extends Applet {
int pictureWidth = 256, pictureHeight = 256;
int pictureArray[] = new int[pictureWidth*pictureHeight];
int data[] = new int[256*256];
/** Creates a new instance of RawDisp */
public void createPicture() {
try{
FileInputStream inp = new FileInputStream("c:\\grey.raw");
int k = 0;
for (int i=0; i<pictureWidth; i++){
for (int j=0; j<pictureHeight; j++) {
for(int h=0; h<data.length; h++){
data[h] = inp.read();
Color c = new Color(data[h],data[h],data[h]);
pictureArray[k++] = c.getRGB();
}
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e,"Exception
Raised",JOptionPane.INFORMATION_MESSAGE);
}
}
public void start() {
createPicture();
}
public void update(Graphics g) {}
Image img;
public void paint(Graphics g) {
img = createImage( new MemoryImageSource(pictureWidth,
pictureHeight, pictureArray, 0, pictureWidth));
g.drawImage(img, 0, 0, this);
}
}
....................
i m unable to display images above 256 x 256 .... pls help me in this
regards....
or if there is some other method to display raw images (e.g. using JAI
API)...i m looking forward for the community to help me.