-/*
-DICOM provides a mechanism for supporting the use of JPEG Image Compression
-through the Encapsulated Format (see PS 3.3 of the DICOM Standard).
-Annex A defines a number of Transfer Syntaxes which reference
-the JPEG Standard and provide a number of lossless (bit preserving)
-and lossy compression schemes.
-In order to facilitate interoperability of implementations conforming
-to the DICOM Standard which elect to use one or more
-of the Transfer Syntaxes for JPEG Image Compression, the following policy is specified:
-
- Any implementation which conforms to the DICOM Standard and has elected
- to support any one of the Transfer Syntaxes for lossless JPEG Image Compression,
- shall support the following lossless compression:
- The subset (first-order horizontal prediction [Selection Value 1) of JPEG Process 14
- (DPCM, non-hierarchical with Huffman coding) (see Annex F of the DICOM Standard).
-
- Any implementation which conforms to the DICOM Standard and has elected
- to support any one of the Transfer Syntaxes for 8-bit lossy JPEG Image Compression,
- shall support the JPEG Baseline Compression (coding Process 1).
-
- Any implementation which conforms to the DICOM Standard and has elected
- to support any one of the Transfer Syntaxes for 12-bit lossy JPEG Image Compression,
- shall support the JPEG Compression Process 4.
-
-Note: The DICOM conformance statement shall differentiate between implementations
-that can simply receive JPEG encoded images and those that can receive and process
-JPEG encoded images (see PS 3.2 of the DICOM Standard).
-
-The use of the DICOM Encapsulated Format to support JPEG Compressed Pixel Data
-implies that the Data Elements which are related to the Native Format Pixel Data encoding
-(e.g. Bits Allocated, Bits Stored, High Bit, Pixel Representation, Rows, Columns, etc.)
-shall contain values which are consistent with the characteristics
-of the uncompressed pixel data from which the compressed Data Stream was derived.
-The Pixel Data characteristics included in the JPEG Interchange Format
-shall be used to decode the compressed data stream.
-
-Run Length Encoding Compression
-
-DICOM provides a mechanism for supporting the use of Run Length Encoding (RLE)
-Compression which is a byte oriented lossless compression scheme through
-the encapsulated Format (see PS 3.3 of this Standard).
-Annex G of the DICOM Standard defines RLE Compression and its Transfer Syntax.
-
-Note: The RLE Compression algorithm described in Annex G
-of the DICOM Standard is the compression used in
-the TIFF 6.0 specification known as the "PackBits" scheme.
-
-The use of the DICOM Encapsulated Format to support RLE Compressed Pixel Data
-implies that the Data Elements which are related to the Native Format Pixel Data encoding (
-e.g. Bits Allocated, Bits Stored, High Bit, Pixel Representation, Rows, Columns, etc.)
-shall contain values which are consistent with the characteristics
-of the uncompressed pixel data from which the compressed data is derived
-*/
+ /* This struct contains the JPEG compression parameters and pointers to
+ * working space (which is allocated as needed by the JPEG library).
+ * It is possible to have several such structures, representing multiple
+ * compression/decompression processes, in existence at once. We refer
+ * to any one struct (and its associated working data) as a "JPEG object".
+ */
+ struct jpeg_compress_struct cinfo;
+ /* This struct represents a JPEG error handler. It is declared separately
+ * because applications often want to supply a specialized error handler
+ * (see the second half of this file for an example). But here we just
+ * take the easy way out and use the standard error handler, which will
+ * print a message on stderr and call exit() if compression fails.
+ * Note that this struct must live as long as the main JPEG parameter
+ * struct, to avoid dangling-pointer problems.
+ */
+ struct jpeg_error_mgr jerr;
+ /* More stuff */
+ //FILE* outfile; /* target FILE* /
+ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
+ int row_stride; /* physical row width in image buffer */
+
+ /* Step 1: allocate and initialize JPEG compression object */
+
+ /* We have to set up the error handler first, in case the initialization
+ * step fails. (Unlikely, but it could happen if you are out of memory.)
+ * This routine fills in the contents of struct jerr, and returns jerr's
+ * address which we place into the link field in cinfo.
+ */
+ cinfo.err = jpeg_std_error(&jerr);
+ /* Now we can initialize the JPEG compression object. */
+ jpeg_create_compress(&cinfo);