Skip to content

Commit 3db190c

Browse files
committed
Better handling for evil DICOM/JP2
1 parent 323a60b commit 3db190c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,12 @@ bool PixmapWriter::PrepareWrite( MediaStorage const & ref_ms )
576576
}
577577
else
578578
{
579+
if( ts_orig == TransferSyntax::JPEG2000Lossless )
580+
{
581+
static const CSComp newvalues2[] = {"ISO_15444_1"};
582+
at3.SetValues( newvalues2, 1 );
583+
ds.Replace( at3.GetAsDataElement() );
584+
}
579585
if( ds.FindDataElement( at1.GetTag() ) ) {
580586
at1.Set( ds );
581587
if( atoi(at1.GetValue().c_str()) != 1 ) {
@@ -584,16 +590,13 @@ bool PixmapWriter::PrepareWrite( MediaStorage const & ref_ms )
584590
ds.Replace( at1.GetAsDataElement() );
585591
}
586592
} else {
593+
at1.SetValue( "01" );
594+
ds.Replace( at1.GetAsDataElement() );
595+
// Assume originally JPEGLossy and override previous value ISO_15444_1
587596
if( pi_orig == PhotometricInterpretation::YBR_FULL_422 ) {
588-
at1.SetValue( "01" );
589-
ds.Replace( at1.GetAsDataElement() );
590-
591597
static const CSComp newvalues2[] = {"ISO_10918_1"};
592598
at3.SetValues( newvalues2, 1 );
593599
ds.Replace( at3.GetAsDataElement() );
594-
} else {
595-
gdcmErrorMacro( "Unhandled Lossy flag for Pixel Data" );
596-
return false;
597600
}
598601
}
599602
}

0 commit comments

Comments
 (0)