怎么用dcm4che 把dcm格式的图片转成jpg格式啊?

我的代码如下:

import java.io.File;
import java.io.IOException;

import org.dcm4che3.tool.dcm2jpg.Dcm2Jpg;
import org.junit.Test;

public class TestDcm2jpg {
    @Test
    public void testDcm2jpg2(){
        try{
            File src = new File("E:/影像实例/1/1.2.392.200036.9123.100.11.12.200000000.2013052710593606.dcm");
            File dest = new File("E:/影像实例/1/1.2.392.200036.9123.100.11.12.200000000.2013052710593606.jpg");
            Dcm2Jpg dcm2jpg= new Dcm2Jpg();           
            dcm2jpg.convert(src, dest);         
            System.out.println("Completed");
        } catch(IOException e){ 
            e.printStackTrace();

        } catch(Exception e){
            e.printStackTrace();
        }
    }
}

运行的时候抛了空指针错误:

 java.lang.NullPointerException
    at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.writeImage(Dcm2Jpg.java:402)
    at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:364)
    at com.boco.test.dcm2jpg.TestDcm2jpg.testDcm2jpg2(TestDcm2jpg.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

查看全部
chengduren2014
chengduren2014
2016/05/24 09:35
  • 点赞
  • 收藏
  • 回答
    私信

1个回复