⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpegfilt.pas

📁 ·ImageEn 2.3.0 ImageEn一组用于图像处理、查看和分析的Delphi控件。能够保存几种图像格式
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    bytes_in_buffer: Longint; { # of bytes remaining in buffer }
    init_source: procedure(cinfo: j_decompress_ptr);
    fill_input_buffer: function(cinfo: j_decompress_ptr): LongBool;
    skip_input_data: procedure(cinfo: j_decompress_ptr; num_bytes: Longint);
    resync_to_restart: function(cinfo: j_decompress_ptr; desired: Integer): LongBool;
    term_source: procedure(cinfo: j_decompress_ptr);
  end;

  { JPEG library memory manager routines }
  jpeg_memory_mgr_ptr = ^jpeg_memory_mgr;
  jpeg_memory_mgr = (*packed*) record
    { Method pointers }
    alloc_small: function(cinfo: j_common_ptr;
      pool_id, sizeofobject: Integer): pointer;
    alloc_large: function(cinfo: j_common_ptr;
      pool_id, sizeofobject: Integer): pointer;
    alloc_sarray: function(cinfo: j_common_ptr; pool_id: Integer;
      samplesperrow: JDIMENSION;
      numrows: JDIMENSION): JSAMPARRAY;
    alloc_barray: pointer;
    request_virt_sarray: pointer;
    request_virt_barray: pointer;
    realize_virt_arrays: pointer;
    access_virt_sarray: pointer;
    access_virt_barray: pointer;
    free_pool: pointer;
    self_destruct: pointer;
    max_memory_to_use: Longint;
  end;

  { Fields shared with jpeg_decompress_struct }// 24
  jpeg_common_struct = (*packed*) record
    err: jpeg_error_mgr_ptr; { Error handler module }
    mem: jpeg_memory_mgr_ptr; { Memory manager module }
    progress: jpeg_progress_mgr_ptr; { Progress monitor, or NIL if none }
    client_data: Pointer; { Available for use by application }
    is_decompressor: LongBool; { so common code can tell which is which }
    global_state: Integer; { for checking call sequence validity }
  end;

  { Progress monitor object }
  jpeg_progress_mgr = (*packed*) record
    progress_monitor: procedure(const cinfo: jpeg_common_struct);
    pass_counter: Integer; { work units completed in this pass }
    pass_limit: Integer; { total number of work units in this pass }
    completed_passes: Integer; { passes completed so far }
    total_passes: Integer; { total number of passes expected }
    // extra info
  end;

  { Master record for a compression instance }
  // attenzione agli allineamenti tra delphi3-4 e Delphi5
  jpeg_compress_struct = packed record
    common: jpeg_common_struct; // 24
    dest: jpeg_destination_mgr_ptr; { Destination for compressed data } // 4
    { Description of source image --- these fields must be filled in by
      outer application before starting compression.  in_color_space must
      be correct before you can even call jpeg_set_defaults(). }
    image_width: JDIMENSION; { input image width } // 4
    image_height: JDIMENSION; { input image height } // 4
    input_components: Integer; { # of color components in input image } // 4
    in_color_space: J_COLOR_SPACE; { colorspace of input image } // 4
    input_gamma: double; { image gamma of input image } // 8
    dummy1: integer;
    // Compression parameters
    data_precision: Integer; { bits of precision in image data } // 4
    num_components: Integer; { # of color components in JPEG image } // 4
    jpeg_color_space: J_COLOR_SPACE; { colorspace of JPEG image } // 4
    comp_info: Pointer; // 4
    quant_tbl_ptrs: array[0..NUM_QUANT_TBLS - 1] of Pointer; // 16
    dc_huff_tbl_ptrs: array[0..NUM_HUFF_TBLS - 1] of Pointer; // 16
    ac_huff_tbl_ptrs: array[0..NUM_HUFF_TBLS - 1] of Pointer; // 16
    arith_dc_L: array[0..NUM_ARITH_TBLS - 1] of UINT8; // 16 { L values for DC arith-coding tables }
    arith_dc_U: array[0..NUM_ARITH_TBLS - 1] of UINT8; // 16 { U values for DC arith-coding tables }
    arith_ac_K: array[0..NUM_ARITH_TBLS - 1] of UINT8; // 16 { Kx values for AC arith-coding tables }
    num_scans: Integer; { # of entries in scan_info array } // 4
    scan_info: Pointer; { script for multi-scan file, or NIL } // 4
    raw_data_in: LongBool; { TRUE=caller supplies downsampled data } // 4
    arith_code: LongBool; { TRUE=arithmetic coding, FALSE=Huffman } // 4
    optimize_coding: LongBool; { TRUE=optimize entropy encoding parms } // 4
    CCIR601_sampling: LongBool; { TRUE=first samples are cosited } // 4
    smoothing_factor: Integer; { 1..100, or 0 for no input smoothing } // 4
    dct_method: J_DCT_METHOD; { DCT algorithm selector } // 4
    restart_interval: UINT; { MCUs per restart, or 0 for no restart } // 4
    restart_in_rows: Integer; { if > 0, MCU rows per restart interval } // 4
    { Parameters controlling emission of special markers. }
    write_JFIF_header: LongBool; { should a JFIF marker be written? } // 4
    JFIF_major_version: UINT8; // What to write for the JFIF version number // (4)
    JFIF_minor_version: UINT8; // (4)
    { These three values are not used by the JPEG code, merely copied }
    { into the JFIF APP0 marker.  density_unit can be 0 for unknown, }
    { 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect }
    { ratio is defined by X_density/Y_density even when density_unit=0. }
    density_unit: UINT8; { JFIF code for pixel size units } // (4)
    dummy2: UINT8;
    X_density: UINT16; { Horizontal pixel density } // (4)
    Y_density: UINT16; { Vertical pixel density } // (4)
    write_Adobe_marker: LongBool; { should an Adobe marker be written? } // 4
    { State variable: index of next scanline to be written to
      jpeg_write_scanlines().  Application may use this to control its
      processing loop, e.g., "while (next_scanline < image_height)". }
    next_scanline: JDIMENSION; { 0 .. image_height-1  } // 4
    { Remaining fields are known throughout compressor, but generally
      should not be touched by a surrounding application. }
    progressive_mode: LongBool; { TRUE if scan script uses progressive mode } // 4
    max_h_samp_factor: Integer; { largest h_samp_factor } // 4
    max_v_samp_factor: Integer; { largest v_samp_factor } // 4
    total_iMCU_rows: JDIMENSION; { # of iMCU rows to be input to coef ctlr } // 4
    comps_in_scan: Integer; { # of JPEG components in this scan } // 4
    cur_comp_info: array[0..MAX_COMPS_IN_SCAN - 1] of Pointer; // 16
    MCUs_per_row: JDIMENSION; { # of MCUs across the image } // 4
    MCU_rows_in_scan: JDIMENSION; { # of MCU rows in the image } // 4
    blocks_in_MCU: Integer; { # of DCT blocks per MCU } // 4
    MCU_membership: array[0..C_MAX_BLOCKS_IN_MCU - 1] of Integer; // 40 (4*10)
    Ss, Se, Ah, Al: Integer; { progressive JPEG parameters for scan } // 16
    { Links to compression subobjects (methods and private variables of modules) }
    master: Pointer; // 4
    main: Pointer; // 4
    prep: Pointer; // 4
    coef: Pointer; // 4
    marker: Pointer; // 4
    cconvert: Pointer; // 4
    downsample: Pointer; // 4
    fdct: Pointer; // 4
    entropy: Pointer; // 4
    script_space: jpeg_scan_info_ptr; // workspace for jpeg_simple_progression // 4
    script_space_size: Integer; // 4
  end;

  { Master record for a decompression instance }
  jpeg_decompress_struct = packed record
    common: jpeg_common_struct;
    { Source of compressed data }
    src: jpeg_source_mgr_ptr;
    { Basic description of image --- filled in by jpeg_read_header(). }
    { Application may inspect these values to decide how to process image. }
    image_width: JDIMENSION; { nominal image width (from SOF marker) }
    image_height: JDIMENSION; { nominal image height }
    num_components: Integer; { # of color components in JPEG image }
    jpeg_color_space: J_COLOR_SPACE; { colorspace of JPEG image }
    { Decompression processing parameters }
    out_color_space: J_COLOR_SPACE; { colorspace for output }
    scale_num, scale_denom: uint; { fraction by which to scale image }
    output_gamma: double; { image gamma wanted in output }
    buffered_image: LongBool; { TRUE=multiple output passes }
    raw_data_out: LongBool; { TRUE=downsampled data wanted }
    dct_method: J_DCT_METHOD; { IDCT algorithm selector }
    do_fancy_upsampling: LongBool; { TRUE=apply fancy upsampling }
    do_block_smoothing: LongBool; { TRUE=apply interblock smoothing }
    quantize_colors: LongBool; { TRUE=colormapped output wanted }
    { the following are ignored if not quantize_colors: }
    dither_mode: J_DITHER_MODE; { type of color dithering to use }
    two_pass_quantize: LongBool; { TRUE=use two-pass color quantization }
    desired_number_of_colors: Integer; { max # colors to use in created colormap }
    { these are significant only in buffered-image mode: }
    enable_1pass_quant: LongBool; { enable future use of 1-pass quantizer }
    enable_external_quant: LongBool; { enable future use of external colormap }
    enable_2pass_quant: LongBool; { enable future use of 2-pass quantizer }
    { Description of actual output image that will be returned to application.
      These fields are computed by jpeg_start_decompress().
      You can also use jpeg_calc_output_dimensions() to determine these values
      in advance of calling jpeg_start_decompress(). }
    output_width: JDIMENSION; { scaled image width }
    output_height: JDIMENSION; { scaled image height }
    out_color_components: Integer; { # of color components in out_color_space }
    output_components: Integer; { # of color components returned }
    { output_components is 1 (a colormap index) when quantizing colors;
      otherwise it equals out_color_components. }
    rec_outbuf_height: Integer; { min recommended height of scanline buffer }
    { If the buffer passed to jpeg_read_scanlines() is less than this many
      rows high, space and time will be wasted due to unnecessary data
      copying. Usually rec_outbuf_height will be 1 or 2, at most 4. }
    { When quantizing colors, the output colormap is described by these
      fields. The application can supply a colormap by setting colormap
      non-NIL before calling jpeg_start_decompress; otherwise a colormap
      is created during jpeg_start_decompress or jpeg_start_output. The map
      has out_color_components rows and actual_number_of_colors columns. }
    actual_number_of_colors: Integer; { number of entries in use }
    colormap: JSAMPARRAY; { The color map as a 2-D pixel array }
    { State variables: these variables indicate the progress of decompression.
      The application may examine these but must not modify them. }
    { Row index of next scanline to be read from jpeg_read_scanlines().
      Application may use this to control its processing loop, e.g.,
      "while (output_scanline < output_height)". }
    output_scanline: JDIMENSION; { 0 .. output_height-1  }
    { Current input scan number and number of iMCU rows completed in scan.
      These indicate the progress of the decompressor input side. }
    input_scan_number: Integer; { Number of SOS markers seen so far }
    input_iMCU_row: JDIMENSION; { Number of iMCU rows completed }
    { The "output scan number" is the notional scan being displayed by the
      output side.  The decompressor will not allow output scan/row number
      to get ahead of input scan/row, but it can fall arbitrarily far behind.}
    output_scan_number: Integer; { Nominal scan number being displayed }
    output_iMCU_row: Integer; { Number of iMCU rows read }
    coef_bits: Pointer;
    { Internal JPEG parameters --- the application usually need not look at
      these fields.  Note that the decompressor output side may not use
      any parameters that can change between scans. }
    { Quantization and Huffman tables are carried forward across input
      datastreams when processing abbreviated JPEG datastreams. }
    quant_tbl_ptrs: array[0..NUM_QUANT_TBLS - 1] of Pointer;
    dc_huff_tbl_ptrs: array[0..NUM_HUFF_TBLS - 1] of Pointer;
    ac_huff_tbl_ptrs: array[0..NUM_HUFF_TBLS - 1] of Pointer;
    { These parameters are never carried across datastreams, since they
      are given in SOF/SOS markers or defined to be reset by SOI. }
    data_precision: Integer; { bits of precision in image data }
    comp_info: Pointer;
    progressive_mode: LongBool; { TRUE if SOFn specifies progressive mode }
    arith_code: LongBool; { TRUE=arithmetic coding, FALSE=Huffman }
    arith_dc_L: array[0..NUM_ARITH_TBLS - 1] of UINT8; { L values for DC arith-coding tables }
    arith_dc_U: array[0..NUM_ARITH_TBLS - 1] of UINT8; { U values for DC arith-coding tables }
    arith_ac_K: array[0..NUM_ARITH_TBLS - 1] of UINT8; { Kx values for AC arith-coding tables }
    restart_interval: UINT; { MCUs per restart interval, or 0 for no restart }
    { These fields record data obtained from optional markers recognized by
      the JPEG library. }
    saw_JFIF_marker: LongBool; { TRUE iff a JFIF APP0 marker was found }
    JFIF_major_version: UINT8; // What to write for the JFIF version number
    JFIF_minor_version: UINT8;
    { Data copied from JFIF marker: }
    density_unit: UINT8; { JFIF code for pixel size units }
    dummy2: UINT8;
    X_density: UINT16; { Horizontal pixel density }
    Y_density: UINT16; { Vertical pixel density }
    saw_Adobe_marker: LongBool; { TRUE iff an Adobe APP14 marker was found }
    Adobe_transform: UINT8; { Color transform code from Adobe marker }
    dummy3: UINT8;
    dummy4: UINT8;
    dummy5: UINT8;
    CCIR601_sampling: LongBool; { TRUE=first samples are cosited }
    (* Aside from the specific data retained from APPn markers known to the
    * library, the uninterpreted contents of any or all APPn and COM markers
    * can be saved in a list for examination by the application.
    *)
    marker_list: jpeg_saved_marker_ptr; // Head of list of saved markers
    { Remaining fields are known throughout decompressor, but generally
      should not be touched by a surrounding application. }
    max_h_samp_factor: Integer; { largest h_samp_factor }
    max_v_samp_factor: Integer; { largest v_samp_factor }
    min_DCT_scaled_size: Integer; { smallest DCT_scaled_size of any component }
    total_iMCU_rows: JDIMENSION; { # of iMCU rows in image }
    sample_range_limit: Pointer; { table for fast range-limiting }
    { These fields are valid during any one scan.
      They describe the components and MCUs actually appearing in the scan.
      Note that the decompressor output side must not use these fields. }
    comps_in_scan: Integer; { # of JPEG components in this scan }
    cur_comp_info: array[0..MAX_COMPS_IN_SCAN - 1] of Pointer;
    MCUs_per_row: JDIMENSION; { # of MCUs across the image }
    MCU_rows_in_scan: JDIMENSION; { # of MCU rows in the image }
    blocks_in_MCU: JDIMENSION; { # of DCT blocks per MCU }
    MCU_membership: array[0..D_MAX_BLOCKS_IN_MCU - 1] of Integer;
    Ss, Se, Ah, Al: Integer; { progressive JPEG parameters for scan }
    { This field is shared between entropy decoder and marker parser.
      It is either zero or the code of a JPEG marker that has been
      read from the data source, but has not yet been processed. }
    unread_marker: Integer;
    { Links to decompression subobjects
      (methods, private variables of modules) }
    master: Pointer;
    main: Pointer;
    coef: Pointer;
    post: Pointer;
    inputctl: Pointer;
    marker: Pointer;
    entropy: Pointer;
    idct: Pointer;
    upsample: Pointer;
    cconvert: Pointer;
    cquantize: Pointer;
  end;

  TJPEGContext = (*packed*) record
    err: jpeg_error_mgr;
    progress: jpeg_progress_mgr;
    FinalDCT: J_DCT_METHOD;
    FinalTwoPassQuant: Boolean;
    FinalDitherMode: J_DITHER_MODE;
    case byte of
      0: (common: jpeg_common_struct);
      1: (d: jpeg_decompress_struct);
      2: (c: jpeg_compress_struct);
  end;

  TIEJPEGDESTMGR = record
    pub: JPEG_DESTINATION_MGR;
    fs: TStream;
    aborting: pboolean;
    buffer: JOCTETPTR;
  end;
  PIEJPEGDESTMGR = ^TIEJPEGDESTMGR;

  TIEJPEGSOURCEMGR = record
    pub: JPEG_SOURCE_MGR;
    fs: TStream;
    start_of_file: boolean;
    aborting: pboolean;
    buffer: JOCTETPTR;
  end;
  PIEJPEGSOURCEMGR = ^TIEJPEGSOURCEMGR;

  { Decompression startup: read start of JPEG datastream to see what's there
     function jpeg_read_header (cinfo : j_decompress_ptr;
                                require_image : LongBool) : Integer;
    Return value is one of: }
const
  JPEG_SUSPENDED = 0; { Suspended due to lack of input data }
  JPEG_HEADER_OK = 1; { Found valid image datastream }
  JPEG_HEADER_TABLES_ONLY = 2; { Found valid table-specs-only datastream }
  { If you pass require_image = TRUE (normal case), you need not check for
    a TABLES_ONLY return code; an abbreviated file will cause an error exit.
    JPEG_SUSPENDED is only possible if you use a data source module that can
    give a suspension return (the stdio source module doesn't). }

  { function jpeg_consume_input (cinfo : j_decompress_ptr) : Integer;
    Return value is one of: }
  JPEG_REACHED_SOS = 1; { Reached start of new scan }
  JPEG_REACHED_EOI = 2; { Reached end of image }
  JPEG_ROW_COMPLETED = 3; { Completed one iMCU row }
  JPEG_SCAN_COMPLETED = 4; { Completed last iMCU row of a scan }

  // Stubs for external C RTL functions referenced by JPEG OBJ files.

function _malloc(size: Integer): Pointer; cdecl;
begin
  {$ifdef IEPROFILE} try IEProfileBegin('_malloc'); {$endif}
  result:=IEAutoAlloc(size);
  {$ifdef IEPROFILE} finally IEProfileEnd; end; {$endif}
end;

procedure _free(P: Pointer); cdecl;
begin
  {$ifdef IEPROFILE} try IEProfileBegin('_free'); {$endif}
  IEAutoFree(P);
  {$ifdef IEPROFILE} finally IEProfileEnd; end; {$endif}
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -