C# Class BitMiracle.LibJpeg.Classic.jpeg_compress_struct

JPEG compression routine.
Inheritance: jpeg_common_struct
Mostra file Open project: prepare/HTML-Renderer Class Usage Examples

Public Properties

Property Type Description
block_size int
color_transform J_COLOR_TRANSFORM
do_fancy_downsampling bool
q_scale_factor int[]
scale_denom int
scale_num int

Public Methods

Method Description
jpeg_abort_compress ( ) : void

Abort processing of a JPEG compression operation.

jpeg_add_quant_table ( int which_tbl, int basic_table, int scale_factor, bool force_baseline ) : void

Allows an arbitrary quantization table to be created.

jpeg_compress_struct ( ) : System

Initializes a new instance of the jpeg_compress_struct class.

jpeg_compress_struct ( jpeg_error_mgr errorManager ) : System

Initializes a new instance of the jpeg_compress_struct class.

jpeg_default_colorspace ( ) : void

Select an appropriate JPEG colorspace based on jpeg_compress_struct.In_color_space, and calls jpeg_compress_struct.jpeg_set_colorspace

This is actually a subroutine of jpeg_set_defaults. It's broken out in case you want to change just the colorspace-dependent JPEG parameters.

jpeg_default_qtables ( bool force_baseline ) : void

Set or change the 'quality' (quantization) setting, using default tables and straight percentage-scaling quality scales. This entry point allows different scalings for luminance and chrominance.

jpeg_finish_compress ( ) : void

Finishes JPEG compression.

If a multipass operating mode was selected, this may do a great deal of work including most of the actual output.

jpeg_quality_scaling ( int quality ) : int

Converts a value on the IJG-recommended quality scale to a linear scaling percentage.

jpeg_set_colorspace ( J_COLOR_SPACE colorspace ) : void

Set the JPEG colorspace (property jpeg_compress_struct.Jpeg_color_space, and choose colorspace-dependent parameters appropriately.

See Special color spaces, below, before using this. A large number of parameters, including all per-component parameters, are set by this routine; if you want to twiddle individual parameters you should call jpeg_set_colorspace before rather than after.

jpeg_set_defaults ( ) : void

Jpeg_set_defaultses this instance.

Uses only the input image's color space (property jpeg_compress_struct.In_color_space, which must already be set in jpeg_compress_struct). Many applications will only need to use this routine and perhaps jpeg_compress_struct.jpeg_set_quality.

jpeg_set_linear_quality ( int scale_factor, bool force_baseline ) : void

Same as jpeg_set_quality except that the generated tables are the sample tables given in the JPEG specification section K.1, multiplied by the specified scale factor.

Note that larger scale factors give lower quality. This entry point is useful for conforming to the Adobe PostScript DCT conventions, but we do not recommend linear scaling as a user-visible quality scale otherwise.

jpeg_set_quality ( int quality, bool force_baseline ) : void

Constructs JPEG quantization tables appropriate for the indicated quality setting.

Note that the exact mapping from quality values to tables may change in future IJG releases as more is learned about DCT quantization.

jpeg_simple_progression ( ) : void

Generates a default scan script for writing a progressive-JPEG file.

This is the recommended method of creating a progressive file, unless you want to make a custom scan sequence. You must ensure that the JPEG color space is set correctly before calling this routine.

jpeg_start_compress ( bool write_all_tables ) : void

Starts JPEG compression.

Before calling this, all parameters and a data destination must be set up.

jpeg_stdio_dest ( Stream outfile ) : void

Sets output stream.

The caller must have already opened the stream, and is responsible for closing it after finishing compression.

jpeg_suppress_tables ( bool suppress ) : void

Forcibly suppress or un-suppress all quantization and Huffman tables.

Marks all currently defined tables as already written (if suppress) or not written (if !suppress). This will control whether they get emitted by a subsequent jpeg_compress_struct.jpeg_start_compress call.
This routine is exported for use by applications that want to produce abbreviated JPEG datastreams.

jpeg_write_coefficients ( jvirt_array coef_arrays ) : void

Compression initialization for writing raw-coefficient data. Useful for lossless transcoding.

Before calling this, all parameters and a data destination must be set up. Call jpeg_finish_compress to actually write the data.

jpeg_write_m_byte ( byte val ) : void

Writes a byte of special marker's data.

jpeg_write_m_header ( int marker, int datalen ) : void

Writes special marker's header.

After calling this method you need to call jpeg_compress_struct.jpeg_write_m_byte exactly the number of times given in the length parameter.
This method lets you empty the output buffer partway through a marker, which might be important when using a suspending data destination module. In any case, if you are using a suspending destination, you should flush its buffer after inserting any special markers.

jpeg_write_marker ( int marker, byte data ) : void

Write a special marker.

This is only recommended for writing COM or APPn markers. Must be called after jpeg_compress_struct.jpeg_start_compress and before first call to jpeg_compress_struct.jpeg_write_scanlines or jpeg_compress_struct.jpeg_write_raw_data.

jpeg_write_raw_data ( byte data, int num_lines ) : int

Alternate entry point to write raw data.

Processes exactly one iMCU row per call, unless suspended. Replaces jpeg_write_scanlines when writing raw downsampled data.

jpeg_write_scanlines ( byte scanlines, int num_lines ) : int

Write some scanlines of data to the JPEG compressor.

We warn about excess calls to jpeg_write_scanlines() since this likely signals an application programmer error. However, excess scanlines passed in the last valid call are "silently" ignored, so that the application need not adjust num_lines for end-of-image when using a multiple-scanline buffer.

jpeg_write_tables ( ) : void

Alternate compression function: just write an abbreviated table file.

Before calling this, all parameters and a data destination must be set up.
To produce a pair of files containing abbreviated tables and abbreviated image data, one would proceed as follows:
Initialize JPEG object
Set JPEG parameters
Set destination to table file
jpeg_write_tables();
Set destination to image file
jpeg_start_compress(false);
Write data...
jpeg_finish_compress();

jpeg_write_tables has the side effect of marking all tables written (same as jpeg_suppress_tables(true)). Thus a subsequent jpeg_start_compress will not re-emit the tables unless it is passed write_all_tables=true.

Private Methods

Method Description
add_huff_table ( JHUFF_TBL &htblptr, byte bits, byte val ) : void

Define a Huffman table

fill_a_scan ( int &scanIndex, int ci, int Ss, int Se, int Ah, int Al ) : void

Support routine: generate one scan for specified component

fill_dc_scans ( int &scanIndex, int ncomps, int Ah, int Al ) : void

Support routine: generate interleaved DC scan if possible, else N scans

fill_scans ( int &scanIndex, int ncomps, int Ss, int Se, int Ah, int Al ) : void

Support routine: generate one scan for each component

initial_setup ( bool transcode_only ) : void

Do computations that are needed before master selection phase

initialize ( ) : void

Initialization of a JPEG compression object

jinit_c_main_controller ( bool need_full_buffer ) : void

Initialize main buffer controller.

jinit_c_master_control ( bool transcode_only ) : void

Initialize master compression control.

jinit_compress_master ( ) : void

Master selection of compression modules. This is done once at the start of processing an image. We determine which modules will be used and give them appropriate initialization calls. This routine is in charge of selecting the modules to be executed and making an initialization call to each one.

jpeg_calc_jpeg_dimensions ( ) : void
jpeg_calc_trans_dimensions ( ) : void
jpeg_set_colorspace_SET_COMP ( int index, int id, int hsamp, int vsamp, int quant, int dctbl, int actbl ) : void
reduce_script ( ) : void
std_huff_tables ( ) : void

Set up the standard Huffman tables (cf. JPEG standard section K.3) IMPORTANT: these are only valid for 8-bit data precision!

transencode_master_selection ( jvirt_array coef_arrays ) : void

Master selection of compression modules for transcoding.

validate_script ( ) : void

Verify that the scan script in scan_info[] is valid; also determine whether it uses progressive JPEG, and set progressive_mode.

Method Details

jpeg_abort_compress() public method

Abort processing of a JPEG compression operation.
public jpeg_abort_compress ( ) : void
return void

jpeg_add_quant_table() public method

Allows an arbitrary quantization table to be created.
public jpeg_add_quant_table ( int which_tbl, int basic_table, int scale_factor, bool force_baseline ) : void
which_tbl int Indicates which table slot to fill.
basic_table int An array of 64 unsigned integers given in normal array order. /// These values are multiplied by scale_factor/100 and then clamped to the range 1..65535 /// (or to 1..255 if force_baseline is true).
/// The basic table should be given in JPEG zigzag order. ///
scale_factor int Multiplier for values in basic_table.
force_baseline bool Defines range of values in basic_table. /// If true - 1..255, otherwise - 1..65535.
return void

jpeg_compress_struct() public method

Initializes a new instance of the jpeg_compress_struct class.
public jpeg_compress_struct ( ) : System
return System

jpeg_compress_struct() public method

Initializes a new instance of the jpeg_compress_struct class.
public jpeg_compress_struct ( jpeg_error_mgr errorManager ) : System
errorManager jpeg_error_mgr The error manager.
return System

jpeg_default_colorspace() public method

Select an appropriate JPEG colorspace based on jpeg_compress_struct.In_color_space, and calls jpeg_compress_struct.jpeg_set_colorspace
This is actually a subroutine of jpeg_set_defaults. It's broken out in case you want to change just the colorspace-dependent JPEG parameters.
public jpeg_default_colorspace ( ) : void
return void

jpeg_default_qtables() public method

Set or change the 'quality' (quantization) setting, using default tables and straight percentage-scaling quality scales. This entry point allows different scalings for luminance and chrominance.
public jpeg_default_qtables ( bool force_baseline ) : void
force_baseline bool if set to true then baseline version is forced.
return void

jpeg_finish_compress() public method

Finishes JPEG compression.
If a multipass operating mode was selected, this may do a great deal of work including most of the actual output.
public jpeg_finish_compress ( ) : void
return void

jpeg_quality_scaling() public static method

Converts a value on the IJG-recommended quality scale to a linear scaling percentage.
public static jpeg_quality_scaling ( int quality ) : int
quality int The IJG-recommended quality scale. Should be 0 (terrible) to 100 (very good).
return int

jpeg_set_colorspace() public method

Set the JPEG colorspace (property jpeg_compress_struct.Jpeg_color_space, and choose colorspace-dependent parameters appropriately.
See Special color spaces, below, before using this. A large number of parameters, including all per-component parameters, are set by this routine; if you want to twiddle individual parameters you should call jpeg_set_colorspace before rather than after.
public jpeg_set_colorspace ( J_COLOR_SPACE colorspace ) : void
colorspace J_COLOR_SPACE The required colorspace.
return void

jpeg_set_defaults() public method

Jpeg_set_defaultses this instance.
Uses only the input image's color space (property jpeg_compress_struct.In_color_space, which must already be set in jpeg_compress_struct). Many applications will only need to use this routine and perhaps jpeg_compress_struct.jpeg_set_quality.
public jpeg_set_defaults ( ) : void
return void

jpeg_set_linear_quality() public method

Same as jpeg_set_quality except that the generated tables are the sample tables given in the JPEG specification section K.1, multiplied by the specified scale factor.
Note that larger scale factors give lower quality. This entry point is useful for conforming to the Adobe PostScript DCT conventions, but we do not recommend linear scaling as a user-visible quality scale otherwise.
public jpeg_set_linear_quality ( int scale_factor, bool force_baseline ) : void
scale_factor int The scale_factor.
force_baseline bool If true, then the quantization table entries are /// constrained to the range 1..255 for full JPEG baseline compatibility. In the current /// implementation, this only makes a difference for quality settings below 25, and it /// effectively prevents very small/low quality files from being generated. The IJG decoder /// is capable of reading the non-baseline files generated at low quality settings when /// force_baseline is false, but other decoders may not be.
return void

jpeg_set_quality() public method

Constructs JPEG quantization tables appropriate for the indicated quality setting.
Note that the exact mapping from quality values to tables may change in future IJG releases as more is learned about DCT quantization.
public jpeg_set_quality ( int quality, bool force_baseline ) : void
quality int The quality value is expressed on the 0..100 scale recommended by IJG.
force_baseline bool If true, then the quantization table entries are constrained /// to the range 1..255 for full JPEG baseline compatibility. In the current implementation, /// this only makes a difference for quality settings below 25, and it effectively prevents /// very small/low quality files from being generated. The IJG decoder is capable of reading /// the non-baseline files generated at low quality settings when force_baseline is false, /// but other decoders may not be.
return void

jpeg_simple_progression() public method

Generates a default scan script for writing a progressive-JPEG file.
This is the recommended method of creating a progressive file, unless you want to make a custom scan sequence. You must ensure that the JPEG color space is set correctly before calling this routine.
public jpeg_simple_progression ( ) : void
return void

jpeg_start_compress() public method

Starts JPEG compression.
Before calling this, all parameters and a data destination must be set up.
public jpeg_start_compress ( bool write_all_tables ) : void
write_all_tables bool Write or not write all quantization and Huffman tables.
return void

jpeg_stdio_dest() public method

Sets output stream.
The caller must have already opened the stream, and is responsible for closing it after finishing compression.
public jpeg_stdio_dest ( Stream outfile ) : void
outfile Stream The output stream.
return void

jpeg_suppress_tables() public method

Forcibly suppress or un-suppress all quantization and Huffman tables.
Marks all currently defined tables as already written (if suppress) or not written (if !suppress). This will control whether they get emitted by a subsequent jpeg_compress_struct.jpeg_start_compress call.
This routine is exported for use by applications that want to produce abbreviated JPEG datastreams.
public jpeg_suppress_tables ( bool suppress ) : void
suppress bool if set to true then suppress tables; /// otherwise unsuppress.
return void

jpeg_write_coefficients() public method

Compression initialization for writing raw-coefficient data. Useful for lossless transcoding.
Before calling this, all parameters and a data destination must be set up. Call jpeg_finish_compress to actually write the data.
public jpeg_write_coefficients ( jvirt_array coef_arrays ) : void
coef_arrays jvirt_array The virtual arrays need not be filled or even realized at the time /// jpeg_write_coefficients is called; indeed, the virtual arrays typically will be realized /// during this routine and filled afterwards. ///
return void

jpeg_write_m_byte() public method

Writes a byte of special marker's data.
public jpeg_write_m_byte ( byte val ) : void
val byte The byte of data.
return void

jpeg_write_m_header() public method

Writes special marker's header.
After calling this method you need to call jpeg_compress_struct.jpeg_write_m_byte exactly the number of times given in the length parameter.
This method lets you empty the output buffer partway through a marker, which might be important when using a suspending data destination module. In any case, if you are using a suspending destination, you should flush its buffer after inserting any special markers.
public jpeg_write_m_header ( int marker, int datalen ) : void
marker int Special marker.
datalen int Length of data associated with the marker.
return void

jpeg_write_marker() public method

Write a special marker.
This is only recommended for writing COM or APPn markers. Must be called after jpeg_compress_struct.jpeg_start_compress and before first call to jpeg_compress_struct.jpeg_write_scanlines or jpeg_compress_struct.jpeg_write_raw_data.
public jpeg_write_marker ( int marker, byte data ) : void
marker int Specify the marker type parameter as .COM for COM or /// .APP0 + n for APPn. (Actually, jpeg_write_marker will let you write any marker type, /// but we don't recommend writing any other kinds of marker)
data byte The data associated with the marker.
return void

jpeg_write_raw_data() public method

Alternate entry point to write raw data.
Processes exactly one iMCU row per call, unless suspended. Replaces jpeg_write_scanlines when writing raw downsampled data.
public jpeg_write_raw_data ( byte data, int num_lines ) : int
data byte The raw data.
num_lines int The number of scanlines for writing.
return int

jpeg_write_scanlines() public method

Write some scanlines of data to the JPEG compressor.
We warn about excess calls to jpeg_write_scanlines() since this likely signals an application programmer error. However, excess scanlines passed in the last valid call are "silently" ignored, so that the application need not adjust num_lines for end-of-image when using a multiple-scanline buffer.
public jpeg_write_scanlines ( byte scanlines, int num_lines ) : int
scanlines byte The array of scanlines.
num_lines int The number of scanlines for writing.
return int

jpeg_write_tables() public method

Alternate compression function: just write an abbreviated table file.
Before calling this, all parameters and a data destination must be set up.
To produce a pair of files containing abbreviated tables and abbreviated image data, one would proceed as follows:
Initialize JPEG object
Set JPEG parameters
Set destination to table file
jpeg_write_tables();
Set destination to image file
jpeg_start_compress(false);
Write data...
jpeg_finish_compress();

jpeg_write_tables has the side effect of marking all tables written (same as jpeg_suppress_tables(true)). Thus a subsequent jpeg_start_compress will not re-emit the tables unless it is passed write_all_tables=true.
public jpeg_write_tables ( ) : void
return void

Property Details

block_size public_oe property

the basic DCT block size: 1..16
public int block_size
return int

color_transform public_oe property

Color transform identifier, writes LSE marker if nonzero
public J_COLOR_TRANSFORM color_transform
return J_COLOR_TRANSFORM

do_fancy_downsampling public_oe property

TRUE=apply fancy downsampling
public bool do_fancy_downsampling
return bool

q_scale_factor public_oe property

corresponding scale factors (percentage, initialized 100).
public int[] q_scale_factor
return int[]

scale_denom public_oe property

The scale denomenator
public int scale_denom
return int

scale_num public_oe property

The scale numerator
public int scale_num
return int