Reputation: 955
I'm currently trying to make an android dicom app Following code opens pictures drom res/drawable in "ussual" image formats, but it doesn't work with .dcm
public class BitmapView extends View
{
public BitmapView(Context context) {
super(context);
}
@Override
public void onDraw(Canvas canvas) {
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.test);
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(bmp, 10, 10, null);
}
}
in the main activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new BitmapView(this));
}
thanks in advance!
Upvotes: 2
Views: 2077
Reputation: 7763
Dicom is a kind of generic container. Inside a Dicom file you can find a huge variety of image formats. From grayscale ones to RGB, from single frame to multiframe ones, with pixel value ranges not in the ordinary 8 bit (24/32 in RGB/RGBA) but also in 12 or 16 bit grayscales.
Dicom files include many elements (fields) indicating the type of the contents and even how such contents should be presented. It is not as simple as converting the Dicom image to BMP.
If you are retrieving Dicom images from a PACS, I would suggest using WADO service. This way, you can obtain Jpeg images (the results of having applied a presentation state to the contents of the Dicom file).
The other option is to use some utility to convert the Dicom file to a more conventional image format. There are some excellent open source tools, such as dcmj2pnm, from the DCMTK toolkit.
Upvotes: 4
Reputation: 4750
Dicom images are not recognized by Android and therefore you cannot open them using a BitmapFactory object.
Recently Imebra has been extended with Java wrappers that call the Imebra native code and comes with a pre-built JAR so you don't have to deal with JNI compilation.
Upvotes: 1
Reputation: 1
In addition to the 2 options mentioned by jap1968 and Paolo, which are both good but require using some method for converting the image on a different platform then viewing it on the Android device and an internet connection, you can actually view the Dicom file itself on the Android device directly if you use a library that supports DCM and its different sub-types. One such toolkit has a free demo application on Google Play here: https://play.google.com/store/apps/details?id=leadtools.datasetdemo
Upvotes: 0