Program: gdcm
Module: $RCSfile: WriteDicomAsJPEG.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 19:06:28 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/10/18 19:54:25 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
std::streambuf* sb = of->rdbuf();
(void)sb;
- //of->close();
- std::ofstream out("/tmp/jpeg2.jpg");
- //out.write( of->str(), of
- out << of->str(); //faster than going through str()
- //out.rdbuf( *sb );
- out.close();
str << samplesPerPixel; //img.components;
fileToBuild->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
- str.str("");
- str << "1.2.840.10008.1.2.4.50";
- fileToBuild->InsertEntryString(str.str(),0x0002,0x0010); // Transfer Syntax UID
-
// Step 2 : Create the output image
// std::cout << "2...";
// if( img.componentSize%8 > 0 )
size_t size = xsize * ysize * 1 /*Z*/
* samplesPerPixel /* * img.componentSize / 8*/;
- //uint8_t *imageData = new uint8_t[size];
+ uint8_t *imageData = new uint8_t[size];
gdcm::FileHelper *fileH = new gdcm::FileHelper(fileToBuild);
//fileH->SetImageData(imageData,size);
assert( size == testedDataSize );
size = of->str().size();
//size = sb->in_avail();
std::cerr << "Size JPEG:" << size << std::endl;
- fileH->SetImageData((uint8_t*)of->str().c_str(), size);
+ //fileH->SetImageData((uint8_t*)of->str().c_str(), size);
+ memcpy(imageData, of->str().c_str(), size);
+ fileH->SetImageData(imageData, size);
//str::string *s = of->str();
//fileH->SetWriteTypeToDcmExplVR();
fileH->SetWriteTypeToJPEG( );
{
std::cerr << "Badddd" << std::endl;
}
+ //of->close();
+ std::ofstream out("/tmp/jpeg2.jpg");
+ //out.write( of->str(), of
+ //out << of->str(); //rdbuf is faster than going through str()
+ out.write( (char*)imageData, size);
+ std::cerr << "JPEG marker is: " << imageData[6] << imageData[7] <<
+ imageData[8] << imageData[9] << std::endl;
+ //out.rdbuf( *sb );
+ out.close();
delete of;
delete f;
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.71 $
+ Date: $Date: 2005/10/18 19:54:26 $
+ Version: $Revision: 1.72 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
binary_write( *fp, el); //element number
// Dicom V3 group 0x0002 is *always* Explicit VR !
- if ( filetype == ExplicitVR || group == 0x0002 )
+ if ( filetype == ExplicitVR || filetype == JPEG || group == 0x0002 )
{
// Special case of delimiters:
if (group == 0xfffe)
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 14:37:18 $
- Version: $Revision: 1.295 $
+ Date: $Date: 2005/10/18 19:54:26 $
+ Version: $Revision: 1.296 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
// Skip if user wants to write an ACR-NEMA file
- if ( filetype == ImplicitVR || filetype == ExplicitVR )
+ if ( filetype == ImplicitVR || filetype == ExplicitVR ||
+ filetype == JPEG )
{
// writing Dicom File Preamble
char filePreamble[128];
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.277 $
+ Date: $Date: 2005/10/18 19:54:26 $
+ Version: $Revision: 1.278 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
e0000->SetString(sLen.str());
}
- int i_lgPix = GetEntryLength(GrPixel, NumPixel);
- if (i_lgPix != -2)
- {
- // no (GrPixel, NumPixel) element
- std::string s_lgPix = Util::Format("%d", i_lgPix+12);
- s_lgPix = Util::DicomString( s_lgPix.c_str() );
- InsertEntryString(s_lgPix,GrPixel, 0x0000);
- }
+ // Derma?.dcm does not have it...let's remove it FIXME FIXME
+ if( writetype != JPEG )
+ {
+ int i_lgPix = GetEntryLength(GrPixel, NumPixel);
+ if (i_lgPix != -2)
+ {
+ // no (GrPixel, NumPixel) element
+ std::string s_lgPix = Util::Format("%d", i_lgPix+12);
+ s_lgPix = Util::DicomString( s_lgPix.c_str() );
+ InsertEntryString(s_lgPix,GrPixel, 0x0000);
+ }
+ }
Document::WriteContent(fp, writetype);
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 18:39:49 $
- Version: $Revision: 1.63 $
+ Date: $Date: 2005/10/18 19:54:27 $
+ Version: $Revision: 1.64 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
break;
case JPEG:
+ SetWriteFileTypeToJPEG();
std::cerr << "Writting as JPEG" << std::endl;
break;
}
/**
* \brief Sets in the File the TransferSyntax to 'Explicit VR Little Endian"
*/
+void FileHelper::SetWriteFileTypeToJPEG()
+{
+ std::string ts = Util::DicomString(
+ Global::GetTS()->GetSpecialTransferSyntax(TS::JPEGBaselineProcess1) );
+
+ DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+ tss->SetString(ts);
+
+ Archive->Push(tss);
+}
+
void FileHelper::SetWriteFileTypeToExplicitVR()
{
std::string ts = Util::DicomString(
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
- Date: $Date: 2005/10/18 18:39:49 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2005/10/18 19:54:27 $
+ Version: $Revision: 1.26 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void RestoreWrite();
void SetWriteFileTypeToACR();
+ void SetWriteFileTypeToJPEG();
void SetWriteFileTypeToExplicitVR();
void SetWriteFileTypeToImplicitVR();
void RestoreWriteFileType();