home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / jlib / jcinit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  3.0 KB  |  82 lines

  1. //-------------------------------------------------------------------------//
  2. //          Windows Graphics Programming: Win32 GDI and DirectDraw         //
  3. //                        ISBN  0-13-086985-6                              //
  4. //                                                                         //
  5. //  Modified by: Yuan, Feng                             www.fengyuan.com   //
  6. //  Changes    : C++, exception, in-memory source, BGR byte order          //
  7. //  Version    : 1.00.000, May 31, 2000                                    //
  8. //-------------------------------------------------------------------------//
  9.  
  10. /*
  11.  * jcinit.c
  12.  *
  13.  * Copyright (C) 1991-1997, Thomas G. Lane.
  14.  * This file is part of the Independent JPEG Group's software.
  15.  * For conditions of distribution and use, see the accompanying README file.
  16.  *
  17.  * This file contains initialization logic for the JPEG compressor.
  18.  * This routine is in charge of selecting the modules to be executed and
  19.  * making an initialization call to each one.
  20.  *
  21.  * Logically, this code belongs in jcmaster.c.  It's split out because
  22.  * linking this routine implies linking the entire compression library.
  23.  * For a transcoding-only application, we want to be able to use jcmaster.c
  24.  * without linking in the whole library.
  25.  */
  26.  
  27. #define JPEG_INTERNALS
  28. #include "jinclude.h"
  29. #include "jpeglib.h"
  30.  
  31.  
  32. /*
  33.  * Master selection of compression modules.
  34.  * This is done once at the start of processing an image.  We determine
  35.  * which modules will be used and give them appropriate initialization calls.
  36.  */
  37.  
  38. GLOBAL(void)
  39. jinit_compress_master (j_compress_ptr cinfo)
  40. {
  41.   /* Initialize master control (includes parameter checking/processing) */
  42.   jinit_c_master_control(cinfo, FALSE /* full compression */);
  43.  
  44.   /* Preprocessing */
  45.   if (! cinfo->raw_data_in) {
  46.     jinit_color_converter(cinfo);
  47.     jinit_downsampler(cinfo);
  48.     jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
  49.   }
  50.   /* Forward DCT */
  51.   jinit_forward_dct(cinfo);
  52.   /* Entropy encoding: either Huffman or arithmetic coding. */
  53.   if (cinfo->arith_code) {
  54.     cinfo->ERREXIT(JERR_ARITH_NOTIMPL);
  55.   } else {
  56.     if (cinfo->progressive_mode) {
  57. #ifdef C_PROGRESSIVE_SUPPORTED
  58.       jinit_phuff_encoder(cinfo);
  59. #else
  60.       ERREXIT(cinfo, JERR_NOT_COMPILED);
  61. #endif
  62.     } else
  63.       jinit_huff_encoder(cinfo);
  64.   }
  65.  
  66.   /* Need a full-image coefficient buffer in any multi-pass mode. */
  67.   jinit_c_coef_controller(cinfo,
  68.         (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
  69.   jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  70.  
  71.   jinit_marker_writer(cinfo);
  72.  
  73.     /* We can now tell the memory manager to allocate virtual arrays. */
  74.     cinfo->mem->realize_virt_arrays ();
  75.  
  76.     /* Write the datastream header (SOI) immediately.
  77.     * Frame and scan headers are postponed till later.
  78.     * This lets application insert special markers after the SOI.
  79.     */
  80.     (*cinfo->marker->write_file_header) (cinfo);
  81. }
  82.