]> Creatis software - gdcm.git/commitdiff
Add WriteDicomAsJPEG
authorjpr <jpr>
Tue, 4 Jul 2006 08:00:43 +0000 (08:00 +0000)
committerjpr <jpr>
Tue, 4 Jul 2006 08:00:43 +0000 (08:00 +0000)
Example/CMakeLists.txt
Example/WriteDicomAsJPEG.cxx

index 87c0624268ba79f1dce85d0e4d440410b39d82e8..50fefef6423ac0cdcef238a292703cccd0b9f378 100644 (file)
@@ -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\r
+INCLUDE_DIRECTORIES(\r
+  ${GDCM_SOURCE_DIR}/src\r
+  ${GDCM_BINARY_DIR}\r
+  ${GDCM_BINARY_DIR}/src  \r
+)\r
+\r
+SET(EXAMPLE_SOURCES\r
+#names starting with 'ex' are examples  \r
+  Txt2Mat\r
+  exReadPapyrus\r
+  exReadWriteFile\r
+  exColorToRGB\r
+  exGrey2RGB\r
+  exGC\r
+  exImageLighten\r
+  #exInLine\r
+  exOverlaysACR\r
+  exOverlaysDCM\r
+  exCurveData\r
+  exExtractTag\r
+  exSerieHelper\r
+  exXCoherentFileSet\r
+  exExtractDicomTags\r
+                \r
+#the following are utilities\r
+  PrintDicomDir\r
+  PrintFile\r
+  MakeDicomDir\r
+  AnonymizeDicomDir # without loading it as a gdcm::DicomDir\r
+  Anonymize         # for full gdcm readable files\r
+  AnonymizeNoLoad   # without loading the Pixel Data\r
+  AnonymizeMultiPatient # without loading the Pixel Data\r
+  PatchHeader\r
+  ToInTag\r
+  #MagnetomVisionToBrucker   \r
+  ReWrite\r
+  ReWriteExtended\r
+  RawToDicom\r
+  TestValidate\r
+  #BatchUncompress\r
+  \r
+#the following will be transformed into 'examples', or 'utilities'\r
+#              or will be removed\r
+#\r
+# Better you don't use them (not fully checked ...)\r
\r
+  FindTags\r
+  FlatHashTablePrint\r
+  Volume2Dicom\r
+  WriteDicomSimple\r
+  WriteRead\r
+  WriteDicomAsJPEG\r
+  exCTPET\r
+  #Slice\r
+)\r
+\r
+FOREACH(name ${EXAMPLE_SOURCES})\r
+  ADD_EXECUTABLE(${name} ${name}.cxx )\r
+  TARGET_LINK_LIBRARIES(${name} gdcm)\r
+  INSTALL_TARGETS(/bin/ ${name})\r
+ENDFOREACH(name)\r
+\r
index 97611a2a190ef42a40036b87d7e1deab14048e01..505677f5e55a14f5ce89180fc898670cfb5cd90c 100644 (file)
@@ -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);