[Gdcm2] Java: pass an image for decompression as byte data
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mikhail T. <mt...@ou...> - 2022-11-09 18:52:07
|
Hi all,
I am trying to create a program similar to the Examples/Java/DecompressImage but with the difference that I would like to read in the file in Java and pass the byte data to gdcm for decompression, ideally avoiding having to copy the data. Anyway here is my naive approach (which does not work):
ImageChangeTransferSyntax change = new ImageChangeTransferSyntax();
change.SetTransferSyntax( new TransferSyntax(TransferSyntax.TSType.ImplicitVRLittleEndian) );
byte[] bytes = Files.readAllBytes( Paths.get(file1));
DataElement dataElementIn = new DataElement();
dataElementIn.SetArray( bytes, bytes.length );
Bitmap bitmap = new Bitmap();
bitmap.SetDataElement( dataElementIn );
change.SetInput( bitmap );
if( !change.Change() )
{
throw new Exception("Could not change: " + file1 );
}
Bitmap image = change.GetOutput();
There are multiple issues here I suppose. But the actual error is this one thrown in the very last line:
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast
Does anybody have any hints how proceed with this? Or maybe even an example of how this should be properly done?
Thanks and best regards
MT
|