Program: gdcm
Module: $RCSfile: gdcmCommon.h,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:27 $
- Version: $Revision: 1.95 $
+ Date: $Date: 2005/10/18 18:39:49 $
+ Version: $Revision: 1.96 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
ImplicitVR,
ACR,
- ACR_LIBIDO
+ ACR_LIBIDO,
+ JPEG
};
/// \brief type of the elements composing a DICOMDIR (for internal use only)
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.62 $
+ Date: $Date: 2005/10/18 18:39:49 $
+ Version: $Revision: 1.63 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
SetWriteFileTypeToACR();
// SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
break;
+ case JPEG:
+ std::cerr << "Writting as JPEG" << std::endl;
+ break;
}
CheckMandatoryElements();
}
bool check = CheckWriteIntegrity(); // verifies length
+ if (WriteType == JPEG ) check = true;
if (check)
{
check = FileInternal->Write(fileName,WriteType);
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2005/10/18 18:39:49 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDebug.h"
#include "gdcmBase.h"
-//#include <iostream>
-
namespace gdcm
void SetWriteTypeToAcr() { SetWriteType(ACR); }
/// \brief Tells the writer we want to write as LibIDO
void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); }
+ void SetWriteTypeToJPEG() { SetWriteType(JPEG); }
/// \brief Tells the writer which format we want to write
/// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
void SetWriteType(FileType format) { WriteType = format; }
Program: gdcm
Module: $RCSfile: gdcmJpeg.cxx,v $
Language: C++
- Date: $Date: 2005/06/24 10:55:59 $
- Version: $Revision: 1.49 $
+ Date: $Date: 2005/10/18 18:39:49 $
+ Version: $Revision: 1.50 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @return 1 on success, 0 on error
*/
-bool gdcm_write_JPEG_file (std::ofstream *fp, void *im_buf,
+bool gdcm_write_JPEG_file (std::ostream *fp, void *im_buf,
int image_width, int image_height, int quality)
{
// exit(1);
//
// }
- jpeg_stdio_dest(&cinfo, fp);
+ assert( 0 );
+ //jpeg_stdio_dest(&cinfo, fp, 0, 0, image_width, image_height, quality);
/* Step 3: set parameters for compression */
typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
- std::ofstream * outfile; /* target stream */
+ std::ostream * outfile; /* target stream */
JOCTET * buffer; /* start of buffer */
+// boolean start_of_file; /* have we gotten any data yet? */
+
+ size_t frag_length; //we have to control this one to spec the size of the frag
+ size_t bytes_written;
} my_destination_mgr;
typedef my_destination_mgr * my_dest_ptr;
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
-#if 0
- if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
- (size_t) OUTPUT_BUF_SIZE)
+ if( dest->bytes_written == dest->frag_length )
+ {
+ // Start the I/O suspension simply by returning false here:
+ return FALSE;
+ }
+
+ size_t output_buf_size = OUTPUT_BUF_SIZE;
+ if( (dest->bytes_written + OUTPUT_BUF_SIZE) > dest->frag_length )
+ {
+ output_buf_size = dest->frag_length - dest->bytes_written;
+ }
+ dest->outfile->write((char*)dest->buffer, output_buf_size);
+ size_t nbytes = output_buf_size; //dest->outfile->gcount();
+
+ if( nbytes <= 0 )
ERREXIT(cinfo, JERR_FILE_WRITE);
-#else
- dest->outfile->write((char*)dest->buffer, OUTPUT_BUF_SIZE);
+
if( dest->outfile->fail() )
ERREXIT(cinfo, JERR_FILE_WRITE);
-#endif
dest->pub.next_output_byte = dest->buffer;
- dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
+ dest->pub.free_in_buffer = nbytes; //OUTPUT_BUF_SIZE;
+ dest->bytes_written += nbytes;
return TRUE;
}
*/
GLOBAL(void)
-jpeg_stdio_dest (j_compress_ptr cinfo, std::ofstream * outfile)
+jpeg_stdio_dest (j_compress_ptr cinfo, std::ostream * outfile, size_t frag_length) //, int flag)
{
my_dest_ptr dest;
dest->pub.empty_output_buffer = reinterpret_cast<boolean_jpeg_compress_struct>(empty_output_buffer);
dest->pub.term_destination = reinterpret_cast<void_jpeg_compress_struct>(term_destination);
dest->outfile = outfile;
+
+ // Need to setup a new buffer, clean bytes_in_buffer and next_input_byte
+ //if( flag )
+ {
+ //dest->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
+ //dest->pub.next_input_byte = NULL; /* until buffer loaded */
+ }
+ //only upate the new fragment, valid for both 'flag' value
+ dest->frag_length = frag_length;
+ dest->bytes_written = 0;
+
}
typedef struct {
struct jpeg_source_mgr pub; /* public fields */
- std::ifstream *infile; /* source stream */
+ std::istream *infile; /* source stream */
JOCTET * buffer; /* start of buffer */
boolean start_of_file; /* have we gotten any data yet? */
*/
GLOBAL(void)
-jpeg_stdio_src (j_decompress_ptr cinfo, std::ifstream * infile, gdcm::JPEGFragment *frag, int flag)
+jpeg_stdio_src (j_decompress_ptr cinfo, std::istream * infile, gdcm::JPEGFragment *frag, int flag)
{
my_src_ptr src;