NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

[platform-dev] Re: how to load image using BufferedImage JAI

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
Fabrizio Giudici
Posted via mailing list.





PostPosted: Wed May 02, 2012 8:30 am    Post subject: [platform-dev] Re: how to load image using BufferedImage JAI Reply with quote

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.





PostPosted: Thu May 03, 2012 9:11 pm    Post subject: [platform-dev] Re: how to load image using BufferedImage JAI Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo