Class jpeg_compress_struct
JPEG compression routine.
Inherited Members
Namespace: BitMiracle.LibJpeg.Classic
Assembly: BitMiracle.LibJpeg.NET.dll
Syntax
public class jpeg_compress_struct : jpeg_common_struct
Constructors
| Improve this Doc View Sourcejpeg_compress_struct()
Initializes a new instance of the jpeg_compress_struct class.
Declaration
public jpeg_compress_struct()
jpeg_compress_struct(jpeg_error_mgr)
Initializes a new instance of the jpeg_compress_struct class.
Declaration
public jpeg_compress_struct(jpeg_error_mgr errorManager)
Parameters
Type | Name | Description |
---|---|---|
jpeg_error_mgr | errorManager | The error manager. |
Fields
| Improve this Doc View Sourceblock_size
the basic DCT block size: 1..16
Declaration
public int block_size
Field Value
Type | Description |
---|---|
System.Int32 |
color_transform
Color transform identifier, writes LSE marker if nonzero
Declaration
public J_COLOR_TRANSFORM color_transform
Field Value
Type | Description |
---|---|
J_COLOR_TRANSFORM |
do_fancy_downsampling
TRUE=apply fancy downsampling
Declaration
public bool do_fancy_downsampling
Field Value
Type | Description |
---|---|
System.Boolean |
q_scale_factor
corresponding scale factors (percentage, initialized 100).
Declaration
public int[] q_scale_factor
Field Value
Type | Description |
---|---|
System.Int32[] |
scale_denom
The scale denomenator
Declaration
public int scale_denom
Field Value
Type | Description |
---|---|
System.Int32 |
scale_num
The scale numerator
Declaration
public int scale_num
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceAc_huff_tbl_ptrs
Gets the Huffman coding tables.
Declaration
public JHUFF_TBL[] Ac_huff_tbl_ptrs { get; }
Property Value
Type | Description |
---|---|
JHUFF_TBL[] | The Huffman coding tables or null if not defined. |
CCIR601_sampling
Gets or sets a value indicating whether first samples are cosited.
Declaration
public bool CCIR601_sampling { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Component_info
Gets the components that appears in SOF.
Declaration
public jpeg_component_info[] Component_info { get; }
Property Value
Type | Description |
---|---|
jpeg_component_info[] | The component info array. |
Data_precision
Gets or sets the number of bits of precision in image data.
Declaration
public int Data_precision { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The data precision. |
Remarks
Default value: 8
The number of bits.
Dc_huff_tbl_ptrs
Gets the Huffman coding tables.
Declaration
public JHUFF_TBL[] Dc_huff_tbl_ptrs { get; }
Property Value
Type | Description |
---|---|
JHUFF_TBL[] | The Huffman coding tables or null if not defined. |
Dct_method
Gets or sets the algorithm used for the DCT step.
Declaration
public J_DCT_METHOD Dct_method { get; set; }
Property Value
Type | Description |
---|---|
J_DCT_METHOD | The DCT algorithm. |
See Also
| Improve this Doc View SourceDensity_unit
Gets or sets the resolution information to be written into the JFIF marker; not used otherwise.
Declaration
public DensityUnit Density_unit { get; set; }
Property Value
Type | Description |
---|---|
DensityUnit | The density unit. |
Remarks
Default value: Unknown
The pixel aspect ratio is defined by
X_density/Y_density
even when Density_unit is Unknown.
See Also
| Improve this Doc View SourceDest
Gets or sets the destination for compressed data
Declaration
public jpeg_destination_mgr Dest { get; set; }
Property Value
Type | Description |
---|---|
jpeg_destination_mgr | The destination for compressed data. |
Image_height
Gets or sets the height of image, in pixels.
Declaration
public int Image_height { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The height of image. |
See Also
| Improve this Doc View SourceImage_width
Gets or sets the width of image, in pixels.
Declaration
public int Image_width { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The width of image. |
See Also
| Improve this Doc View SourceIn_color_space
Gets or sets the color space of source image.
Declaration
public J_COLOR_SPACE In_color_space { get; set; }
Property Value
Type | Description |
---|---|
J_COLOR_SPACE | The color space. |
See Also
| Improve this Doc View SourceInput_components
Gets or sets the number of color channels (components per pixel)
Declaration
public int Input_components { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of color channels. |
See Also
| Improve this Doc View SourceIsDecompressor
Retrieves false
because this is not decompressor.
Declaration
public override bool IsDecompressor { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Overrides
| Improve this Doc View SourceJFIF_major_version
Gets or sets the version number to be written into the JFIF marker.
Declaration
public byte JFIF_major_version { get; set; }
Property Value
Type | Description |
---|---|
System.Byte | The version number to be written into the JFIF marker. |
Remarks
jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). You should set it to 1.02 (major=1, minor=2) if you plan to write any JFIF 1.02 extension markers.
See Also
| Improve this Doc View SourceJFIF_minor_version
Gets or sets the version number to be written into the JFIF marker.
Declaration
public byte JFIF_minor_version { get; set; }
Property Value
Type | Description |
---|---|
System.Byte | The version number to be written into the JFIF marker. |
Remarks
jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). You should set it to 1.02 (major=1, minor=2) if you plan to write any JFIF 1.02 extension markers.
See Also
| Improve this Doc View SourceJpeg_color_space
Gets or sets the JPEG color space.
Declaration
public J_COLOR_SPACE Jpeg_color_space { get; set; }
Property Value
Type | Description |
---|---|
J_COLOR_SPACE | The JPEG color space. |
Remarks
We recommend to use jpeg_set_colorspace(J_COLOR_SPACE) if you want to change this.
Max_v_samp_factor
Gets the largest vertical sample factor.
Declaration
public int Max_v_samp_factor { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The largest vertical sample factor. |
See Also
| Improve this Doc View SourceNext_scanline
Gets the index of next scanline to be written to jpeg_write_scanlines(Byte[][], Int32).
Declaration
public int Next_scanline { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Range: from 0 to (Image_height - 1) |
Remarks
Application may use this to control its processing loop, e.g., "while (Next_scanline < Image_height)"
See Also
| Improve this Doc View SourceNum_components
Gets or sets the number of color components for JPEG color space.
Declaration
public int Num_components { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of color components for JPEG color space. |
Optimize_coding
Gets or sets a value indicating a way of using Huffman coding tables.
Declaration
public bool Optimize_coding { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When this is true
, you need not supply Huffman tables at all, and any you do supply will be overwritten.
See Also
| Improve this Doc View SourceQuant_tbl_ptrs
Gets the coefficient quantization tables.
Declaration
public JQUANT_TBL[] Quant_tbl_ptrs { get; }
Property Value
Type | Description |
---|---|
JQUANT_TBL[] | The coefficient quantization tables or null if not defined. |
Raw_data_in
Gets or sets a value indicating whether you will be supplying raw data.
Declaration
public bool Raw_data_in { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Default value: false
See Also
| Improve this Doc View SourceRestart_in_rows
Gets or sets the interval in MCU rows.
Declaration
public int Restart_in_rows { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The restart interval in MCU rows. |
Remarks
Default value: 0
If Restart_in_rows is not 0, then Restart_interval is set
after the image width in MCUs is computed.
One restart marker per MCU row is often a good choice.
The overhead of restart markers is higher in grayscale JPEG files than in color files, and MUCH higher in progressive JPEGs. If you use restarts, you may want to use larger intervals in those cases.
See Also
| Improve this Doc View SourceRestart_interval
Gets or sets the exact interval in MCU blocks.
Declaration
public int Restart_interval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The restart interval. |
Remarks
Default value: 0
One restart marker per MCU row is often a good choice. The overhead of restart markers
is higher in grayscale JPEG files than in color files, and MUCH higher in progressive JPEGs.
If you use restarts, you may want to use larger intervals in those cases.
See Also
| Improve this Doc View SourceSmoothing_factor
Gets or sets the coefficient of image smoothing.
Declaration
public int Smoothing_factor { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The coefficient of image smoothing. |
Remarks
Default value: 0
If non-zero, the input image is smoothed; the value should be 1 for minimal smoothing
to 100 for maximum smoothing.
See Also
| Improve this Doc View SourceWrite_Adobe_marker
Gets or sets a value indicating whether to emit Adobe APP14 marker.
Declaration
public bool Write_Adobe_marker { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | If |
Remarks
jpeg_set_defaults() and jpeg_set_colorspace(J_COLOR_SPACE)
set this true
if JPEG color space RGB, CMYK, or YCCK is selected, otherwise false
.
It is generally a bad idea to set both Write_JFIF_header and
Write_Adobe_marker.
In fact, you probably shouldn't change the default settings at all - the default behavior ensures that the JPEG file's
color space can be recognized by the decoder.
See Also
| Improve this Doc View SourceWrite_JFIF_header
Gets or sets a value indicating whether the JFIF APP0 marker is emitted.
Declaration
public bool Write_JFIF_header { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
jpeg_set_defaults() and
jpeg_set_colorspace(J_COLOR_SPACE) set this true
if a JFIF-legal JPEG color space (i.e., YCbCr or grayscale) is selected, otherwise false
.
See Also
| Improve this Doc View SourceX_density
Gets or sets the horizontal component of pixel ratio.
Declaration
public short X_density { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 | The horizontal density. |
Remarks
Default value: 1
See Also
| Improve this Doc View SourceY_density
Gets or sets the vertical component of pixel ratio.
Declaration
public short Y_density { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 | The vertical density. |
Remarks
Default value: 1
See Also
Methods
| Improve this Doc View Sourcejpeg_abort_compress()
Abort processing of a JPEG compression operation.
Declaration
public void jpeg_abort_compress()
jpeg_add_quant_table(Int32, Int32[], Int32, Boolean)
Allows an arbitrary quantization table to be created.
Declaration
public void jpeg_add_quant_table(int which_tbl, int[] basic_table, int scale_factor, bool force_baseline)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | which_tbl | Indicates which table slot to fill. |
System.Int32[] | basic_table | An array of 64 unsigned integers given in normal array order.
These values are multiplied by |
System.Int32 | scale_factor | Multiplier for values in |
System.Boolean | force_baseline | Defines range of values in |
See Also
| Improve this Doc View Sourcejpeg_default_colorspace()
Select an appropriate JPEG colorspace based on In_color_space, and calls jpeg_set_colorspace(J_COLOR_SPACE)
Declaration
public void jpeg_default_colorspace()
Remarks
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.
See Also
| Improve this Doc View Sourcejpeg_default_qtables(Boolean)
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.
Declaration
public void jpeg_default_qtables(bool force_baseline)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | force_baseline | if set to |
jpeg_finish_compress()
Finishes JPEG compression.
Declaration
public void jpeg_finish_compress()
Remarks
If a multipass operating mode was selected, this may do a great deal of work including most of the actual output.
jpeg_quality_scaling(Int32)
Converts a value on the IJG-recommended quality scale to a linear scaling percentage.
Declaration
public static int jpeg_quality_scaling(int quality)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | quality | The IJG-recommended quality scale. Should be 0 (terrible) to 100 (very good). |
Returns
Type | Description |
---|---|
System.Int32 | The linear scaling percentage. |
See Also
| Improve this Doc View Sourcejpeg_set_colorspace(J_COLOR_SPACE)
Set the JPEG colorspace (property Jpeg_color_space, and choose colorspace-dependent parameters appropriately.
Declaration
public void jpeg_set_colorspace(J_COLOR_SPACE colorspace)
Parameters
Type | Name | Description |
---|---|---|
J_COLOR_SPACE | colorspace | The required colorspace. |
Remarks
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.
See Also
| Improve this Doc View Sourcejpeg_set_defaults()
Jpeg_set_defaultses this instance.
Declaration
public void jpeg_set_defaults()
Remarks
Uses only the input image's color space (property In_color_space, which must already be set in jpeg_compress_struct). Many applications will only need to use this routine and perhaps jpeg_set_quality(Int32, Boolean).
See Also
| Improve this Doc View Sourcejpeg_set_linear_quality(Int32, Boolean)
Same as jpeg_set_quality(Int32, Boolean) except that the generated tables are the sample tables given in the JPEG specification section K.1, multiplied by the specified scale factor.
Declaration
public void jpeg_set_linear_quality(int scale_factor, bool force_baseline)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | scale_factor | The scale_factor. |
System.Boolean | force_baseline | If |
Remarks
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.
See Also
| Improve this Doc View Sourcejpeg_set_quality(Int32, Boolean)
Constructs JPEG quantization tables appropriate for the indicated quality setting.
Declaration
public void jpeg_set_quality(int quality, bool force_baseline)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | quality | The quality value is expressed on the 0..100 scale recommended by IJG. |
System.Boolean | force_baseline | If |
Remarks
Note that the exact mapping from quality values to tables may change in future IJG releases as more is learned about DCT quantization.
See Also
| Improve this Doc View Sourcejpeg_simple_progression()
Generates a default scan script for writing a progressive-JPEG file.
Declaration
public void jpeg_simple_progression()
Remarks
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.
See Also
| Improve this Doc View Sourcejpeg_start_compress(Boolean)
Starts JPEG compression.
Declaration
public void jpeg_start_compress(bool write_all_tables)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | write_all_tables | Write or not write all quantization and Huffman tables. |
Remarks
Before calling this, all parameters and a data destination must be set up.
See Also
| Improve this Doc View Sourcejpeg_stdio_dest(Stream)
Sets output stream.
Declaration
public void jpeg_stdio_dest(Stream outfile)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | outfile | The output stream. |
Remarks
The caller must have already opened the stream, and is responsible for closing it after finishing compression.
See Also
| Improve this Doc View Sourcejpeg_suppress_tables(Boolean)
Forcibly suppress or un-suppress all quantization and Huffman tables.
Declaration
public void jpeg_suppress_tables(bool suppress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | suppress | if set to |
Remarks
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_start_compress(Boolean) call.
This routine is exported for use by applications that want to produce abbreviated JPEG datastreams.
jpeg_write_coefficients(jvirt_array<JBLOCK>[])
Compression initialization for writing raw-coefficient data. Useful for lossless transcoding.
Declaration
public void jpeg_write_coefficients(jvirt_array<JBLOCK>[] coef_arrays)
Parameters
Type | Name | Description |
---|---|---|
jvirt_array<JBLOCK>[] | coef_arrays | The virtual arrays need not be filled or even realized at the time
|
Remarks
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)
Writes a byte of special marker's data.
Declaration
public void jpeg_write_m_byte(byte val)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | val | The byte of data. |
See Also
| Improve this Doc View Sourcejpeg_write_m_header(Int32, Int32)
Writes special marker's header.
Declaration
public void jpeg_write_m_header(int marker, int datalen)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | marker | Special marker. |
System.Int32 | datalen | Length of data associated with the marker. |
Remarks
After calling this method you need to call jpeg_write_m_byte(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.
See Also
| Improve this Doc View Sourcejpeg_write_marker(Int32, Byte[])
Write a special marker.
Declaration
public void jpeg_write_marker(int marker, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | marker | Specify the marker type parameter as JPEG_MARKER.COM for COM or JPEG_MARKER.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) |
System.Byte[] | data | The data associated with the marker. |
Remarks
This is only recommended for writing COM or APPn markers. Must be called after jpeg_start_compress(Boolean) and before first call to jpeg_write_scanlines(Byte[][], Int32) or jpeg_write_raw_data(Byte[][][], Int32).
See Also
| Improve this Doc View Sourcejpeg_write_raw_data(Byte[][][], Int32)
Alternate entry point to write raw data.
Declaration
public int jpeg_write_raw_data(byte[][][] data, int num_lines)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[][][] | data | The raw data. |
System.Int32 | num_lines | The number of scanlines for writing. |
Returns
Type | Description |
---|---|
System.Int32 | The number of lines actually written. |
Remarks
Processes exactly one iMCU row per call, unless suspended. Replaces jpeg_write_scanlines(Byte[][], Int32) when writing raw downsampled data.
jpeg_write_scanlines(Byte[][], Int32)
Write some scanlines of data to the JPEG compressor.
Declaration
public int jpeg_write_scanlines(byte[][] scanlines, int num_lines)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[][] | scanlines | The array of scanlines. |
System.Int32 | num_lines | The number of scanlines for writing. |
Returns
Type | Description |
---|---|
System.Int32 | The return value will be the number of lines actually written. |
Remarks
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.
See Also
| Improve this Doc View Sourcejpeg_write_tables()
Alternate compression function: just write an abbreviated table file.
Declaration
public void jpeg_write_tables()
Remarks
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(Boolean)
Write data...
jpeg_finish_compress()
jpeg_write_tables has the side effect of marking all tables written
(same as jpeg_suppress_tables(Boolean)).
Thus a subsequent jpeg_start_compress(Boolean)
will not re-emit the tables unless it is passed write_all_tables=true
.