NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Fabrizio Giudici Posted via mailing list.
|
Posted: Wed May 02, 2012 8:30 am Post subject: [platform-dev] Re: how to load image using BufferedImage JAI |
|
|
On Fri, 27 Apr 2012 16:21:23 +0200, purav14 <address-removed> wrote:
| Quote: | hie to all I am developing dicom application just i have to started
,,first
of i want to load DICOM image using BufferedImage in netbeans platform
but
getting some exception so what exactly way to load image by using
it...plz
reply me as soon as possible....thanks in advance...
|
How can one help you if you don't give details about the exceptions?
--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
address-removed
http://tidalwave.it - http://fabriziogiudici.it |
|
| Back to top |
|
 |
purav14 Posted via mailing list.
|
Posted: Thu May 03, 2012 9:11 pm Post subject: [platform-dev] Re: how to load image using BufferedImage JAI |
|
|
i got only array index out of bound exception ,,my source code which i
developed given below....pls give me idea where i am wrong..
package newone;
import com.sun.media.jai.codec.ByteArraySeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.SeekableStream;
import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.image.RenderedImage;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.channels.FileChannel;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import javax.swing.*;
public class Newone {
public static void main(String args[]) {
RenderedImage image = null;
RenderedOp result = null;
// String format="DICOM";
Image imagenew = null;
JLabel jLabel1 = new JLabel();
ImageIcon img = new ImageIcon();
jLabel1.setIcon(img);
boolean b;
// File file = new File("E:/dicdemo1.dcm");
try{
FileInputStream in = new FileInputStream("E:/mammo.DICOM");
FileChannel channel = in.getChannel();
DoubleBuffer buffer;
ByteBuffer buffer1 = ByteBuffer.allocate((int) channel.size());
buffer1.rewind();
buffer = ((ByteBuffer) buffer1.rewind()).asDoubleBuffer();
channel.read(buffer1);
SeekableStream stream = new ByteArraySeekableStream(buffer1.array())
{};
String[] names = ImageCodec.getDecoderNames(stream);
ImageDecoder dec = ImageCodec.createImageDecoder(names[0],
stream,null );
RenderedImage rim = dec.decodeAsRenderedImage();
imagenew = PlanarImage.wrapRenderedImage(rim).getAsBufferedImage();
}catch(IOException e){ e.printStackTrace();}
JTabbedPane pane = new JTabbedPane();
// pane.addTab("imageOriginal", new JScrollPane(new JLabel(new
ImageIcon(x))));
pane.addTab("LoadedImage", new JScrollPane(new JLabel(new
ImageIcon(imagenew))));
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// jsp.setPreferredSize(new Dimension(450,450));
f.setLayout(new BorderLayout());
f.add(pane);
//f.add(jsp, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
private static boolean canReadExtention(String filename){
Iterator iter =ImageIO.getImageReadersBySuffix(filename);
return iter.hasNext();
}
}
--
View this message in context: http://netbeans-org.1045718.n5.nabble.com/how-to-load-image-using-BufferedImage-JAI-tp5670427p5682879.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|