Hi, i ve got a raw image to be displayed, i ve used the program below
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.
Oliver Wong - 10 Feb 2006 18:43 GMT
[snipped code that generates image]
> To display this image i m using this program..........
[snipped most of the code]
> int pictureWidth = 256, pictureHeight = 256;
> int pictureArray[] = new int[pictureWidth*pictureHeight];
> int data[] = new int[256*256];
[snipped most of the code]
> 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.
Could it be because the dimensions 256x256 are hard coded in the
program? Wouldn't it make more sense to try to infer the dimensions from the
image file, or if that's impossible, allow the user to specify the desired
dimensions?
- Oliver
hussainak@gmail.com - 10 Feb 2006 19:11 GMT
thanx for taking out time to reply..... pls try this program on ur JVM
and increase the images dim and lemme know
Oliver Wong - 10 Feb 2006 20:14 GMT
> thanx for taking out time to reply..... pls try this program on ur JVM
> and increase the images dim and lemme know
Well...
I'd rather not...
And at any rate, you never even specify what the program is supposed to
do, so even if I did run it, I'd never know if it was doing what you
intended or not.
- Oliver
hussainak@gmail.com - 10 Feb 2006 20:39 GMT
> > thanx for taking out time to reply..... pls try this program on ur JVM
> > and increase the images dim and lemme know
[quoted text clipped - 8 lines]
>
> - Oliver
ummm...ok....my first program generates a raw image file (u can view it
using PhotoShop) .... i ve written the second program to display the
raw format file ... so that i need not open the file in PhotoShop to
see it....but i ve a problem, i cannot view files larger than 256 x 256
:(
Oliver Wong - 10 Feb 2006 21:17 GMT
>> > thanx for taking out time to reply..... pls try this program on ur JVM
>> > and increase the images dim and lemme know
[quoted text clipped - 15 lines]
> see it....but i ve a problem, i cannot view files larger than 256 x 256
> :(
Okay, well I can tell you right now that your program doesn't do what
you just described above, even if the file is "smaller than or equal to"
256x256.
Your "Rawtest" program actually generates an image consisting of 256
intensity levels. This could be a 1x256 image, or a 2x128 image, or a 4x64
image, or a 8x32 image, or a 16x16 image, etc. But it would never describe a
256x256 image. A 256x256 resolution image would contain 65536 intensity
levels.
Your "RawDisp" applet always displays a 256x256 image, regardless of the
dimensions of the file you feed it.
- Oliver
hussainak@gmail.com - 10 Feb 2006 23:32 GMT
> >> > thanx for taking out time to reply..... pls try this program on ur JVM
> >> > and increase the images dim and lemme know
[quoted text clipped - 30 lines]
>
> - Oliver
yes...exactly.....there my problem lies ... so how do i go abt it? how
should that be solved...anybody here having hands on expirience with
JAI(Java Advanced Imaging) API?
pls help me if you do..... i just need a small example to start with
JAI ....
Oliver Wong - 13 Feb 2006 14:42 GMT
>> <hussainak@gmail.com> wrote in message
>> > ummm...ok....my first program generates a raw image file (u can view it
[quoted text clipped - 25 lines]
> pls help me if you do..... i just need a small example to start with
> JAI ....
The problem is not with JAI. Your second program should already be
drawing something to screen; the problem is what it's drawing is NOT the
contents of the file on the disk. You need to rethink the logic in your
for-loops.
- Oliver
Roedy Green - 10 Feb 2006 21:20 GMT
>i m unable to display images above 256 x 256
you have hard coded those constants in. By any chance did you forget
to change one of them, and of course the size of the applet itself?
Try using a
static final int MAX_PIXEL_WIDTH = 256;

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
hussainak@gmail.com - 10 Feb 2006 23:50 GMT
>Try using a
>static final int MAX_PIXEL_WIDTH = 256;
pls provide me with a small example