From 3d1a0a5fcd71ece6b1c4f8a13ff9dd7a99855250 Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 4 Jul 2006 08:00:43 +0000 Subject: [PATCH] Add WriteDicomAsJPEG --- Example/CMakeLists.txt | 122 ++++++++++++++++++----------------- Example/WriteDicomAsJPEG.cxx | 16 ++++- 2 files changed, 76 insertions(+), 62 deletions(-) diff --git a/Example/CMakeLists.txt b/Example/CMakeLists.txt index 87c06242..50fefef6 100644 --- a/Example/CMakeLists.txt +++ b/Example/CMakeLists.txt @@ -1,59 +1,63 @@ -# include stuff -INCLUDE_DIRECTORIES( - ${GDCM_SOURCE_DIR}/src - ${GDCM_BINARY_DIR} -) - -SET(EXAMPLE_SOURCES -#names starting with 'ex' are examples - exReadPapyrus - exReadWriteFile - exColorToRGB - exGrey2RGB - exGC - exImageLighten - #exOverlaysACR - exOverlaysDCM - exCurveData - exExtractTag - exSerieHelper - exXCoherentFileSet - exExtractDicomTags - -#the following are utilities - PrintDicomDir - PrintFile - MakeDicomDir - AnonymizeDicomDir # without loading it as a gdcm::DicomDir - Anonymize # for full gdcm readable files - AnonymizeNoLoad # without loading the Pixel Data - AnonymizeMultiPatient # without loading the Pixel Data - PatchHeader - ToInTag - #MagnetomVisionToBrucker - ReWrite - ReWriteExtended - RawToDicom - TestValidate - #BatchUncompress - -#the following will be transformed into 'examples', or 'utilities' -# or will be removed -# -# Better you don't use them (not fully checked ...) - - FindTags - FlatHashTablePrint - Volume2Dicom - WriteDicomSimple - WriteRead - exCTPET - #Slice -) - -FOREACH(name ${EXAMPLE_SOURCES}) - ADD_EXECUTABLE(${name} ${name}.cxx ) - TARGET_LINK_LIBRARIES(${name} gdcm) - INSTALL_TARGETS(/bin/ ${name}) -ENDFOREACH(name) - +# include stuff +INCLUDE_DIRECTORIES( + ${GDCM_SOURCE_DIR}/src + ${GDCM_BINARY_DIR} + ${GDCM_BINARY_DIR}/src +) + +SET(EXAMPLE_SOURCES +#names starting with 'ex' are examples + Txt2Mat + exReadPapyrus + exReadWriteFile + exColorToRGB + exGrey2RGB + exGC + exImageLighten + #exInLine + exOverlaysACR + exOverlaysDCM + exCurveData + exExtractTag + exSerieHelper + exXCoherentFileSet + exExtractDicomTags + +#the following are utilities + PrintDicomDir + PrintFile + MakeDicomDir + AnonymizeDicomDir # without loading it as a gdcm::DicomDir + Anonymize # for full gdcm readable files + AnonymizeNoLoad # without loading the Pixel Data + AnonymizeMultiPatient # without loading the Pixel Data + PatchHeader + ToInTag + #MagnetomVisionToBrucker + ReWrite + ReWriteExtended + RawToDicom + TestValidate + #BatchUncompress + +#the following will be transformed into 'examples', or 'utilities' +# or will be removed +# +# Better you don't use them (not fully checked ...) + + FindTags + FlatHashTablePrint + Volume2Dicom + WriteDicomSimple + WriteRead + WriteDicomAsJPEG + exCTPET + #Slice +) + +FOREACH(name ${EXAMPLE_SOURCES}) + ADD_EXECUTABLE(${name} ${name}.cxx ) + TARGET_LINK_LIBRARIES(${name} gdcm) + INSTALL_TARGETS(/bin/ ${name}) +ENDFOREACH(name) + diff --git a/Example/WriteDicomAsJPEG.cxx b/Example/WriteDicomAsJPEG.cxx index 97611a2a..505677f5 100644 --- a/Example/WriteDicomAsJPEG.cxx +++ b/Example/WriteDicomAsJPEG.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomAsJPEG.cxx,v $ Language: C++ - Date: $Date: 2006/01/27 10:03:23 $ - Version: $Revision: 1.10 $ + Date: $Date: 2006/07/04 08:00:43 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -236,6 +236,7 @@ bool InitializeJpeg(std::ostream *fp, int fragment_size, int image_width, int im */ if (sample_pixel == 3) { + assert( sample_pixel == 1 ); row_stride = image_width * 3;/* JSAMPLEs per row in image_buffer */ } else @@ -326,7 +327,15 @@ bool CreateOneFrame (std::ostream *fp, void *input_buffer, int fragment_size, static int i = 0; JpegPair &jp = v[i]; jp.second = end-beg; - std::cerr << "DIFF: " << i <<" -> " << end-beg << std::endl; + + if( ((end-beg) % 2) ) + { + fp->put( '\0' ); + jp.second += 1; + } + assert( !(jp.second % 2) ); + std::cerr << "DIFF: " << i <<" -> " << jp.second << std::endl; + ++i; //JpegPair &jp = v[0]; @@ -394,6 +403,7 @@ int main(int argc, char *argv[]) WriteDICOMItems(of, JpegFragmentSize); CreateOneFrame(of, pImageData, fragment_size, xsize, ysize, zsize, samplesPerPixel, quality, JpegFragmentSize); + assert( !(fragment_size % 2) ); pImageData += fragment_size; } CloseJpeg(of, JpegFragmentSize); -- 2.46.1