Show / Hide Table of Contents

Class jpeg_compress_struct

JPEG compression routine.

Inheritance
System.Object
jpeg_common_struct
jpeg_compress_struct
Inherited Members
jpeg_common_struct.Progress
jpeg_common_struct.Err
jpeg_common_struct.Version
jpeg_common_struct.Copyright
jpeg_common_struct.CreateSamplesArray(Int32, Int32)
jpeg_common_struct.CreateBlocksArray(Int32, Int32)
jpeg_common_struct.AllocJpegSamples(Int32, Int32)
jpeg_common_struct.jpeg_abort()
jpeg_common_struct.jpeg_destroy()
jpeg_common_struct.ERREXIT(J_MESSAGE_CODE)
jpeg_common_struct.ERREXIT(J_MESSAGE_CODE, Object[])
jpeg_common_struct.ERREXIT(Int32, Object[])
jpeg_common_struct.WARNMS(J_MESSAGE_CODE)
jpeg_common_struct.WARNMS(J_MESSAGE_CODE, Object[])
jpeg_common_struct.WARNMS(Int32, Object[])
jpeg_common_struct.TRACEMS(Int32, J_MESSAGE_CODE)
jpeg_common_struct.TRACEMS(Int32, J_MESSAGE_CODE, Object[])
jpeg_common_struct.TRACEMS(Int32, Int32, Object[])
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: BitMiracle.LibJpeg.Classic
Assembly: BitMiracle.LibJpeg.NET.dll
Syntax
public class jpeg_compress_struct : jpeg_common_struct

Constructors

| Improve this Doc View Source

jpeg_compress_struct()

Initializes a new instance of the jpeg_compress_struct class.

Declaration
public jpeg_compress_struct()
| Improve this Doc View Source

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 Source

block_size

the basic DCT block size: 1..16

Declaration
public int block_size
Field Value
Type Description
System.Int32
| Improve this Doc View Source

color_transform

Color transform identifier, writes LSE marker if nonzero

Declaration
public J_COLOR_TRANSFORM color_transform
Field Value
Type Description
J_COLOR_TRANSFORM
| Improve this Doc View Source

do_fancy_downsampling

TRUE=apply fancy downsampling

Declaration
public bool do_fancy_downsampling
Field Value
Type Description
System.Boolean
| Improve this Doc View Source

q_scale_factor

corresponding scale factors (percentage, initialized 100).

Declaration
public int[] q_scale_factor
Field Value
Type Description
System.Int32[]
| Improve this Doc View Source

scale_denom

The scale denomenator

Declaration
public int scale_denom
Field Value
Type Description
System.Int32
| Improve this Doc View Source

scale_num

The scale numerator

Declaration
public int scale_num
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

Ac_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.

| Improve this Doc View Source

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

true if first samples are cosited; otherwise, false.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
Compression parameter selection
| Improve this Doc View Source

Density_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
X_density
Y_density
Compression parameter selection
| Improve this Doc View Source

Dest

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.

| Improve this Doc View Source

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
Compression details
| Improve this Doc View Source

Image_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
Compression details
| Improve this Doc View Source

In_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
Compression details
Special color spaces
| Improve this Doc View Source

Input_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
Compression details
| Improve this Doc View Source

IsDecompressor

Retrieves false because this is not decompressor.

Declaration
public override bool IsDecompressor { get; }
Property Value
Type Description
System.Boolean

false

Overrides
jpeg_common_struct.IsDecompressor
| Improve this Doc View Source

JFIF_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
JFIF_minor_version
Write_JFIF_header
| Improve this Doc View Source

JFIF_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
JFIF_major_version
Write_JFIF_header
| Improve this Doc View Source

Jpeg_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.

| Improve this Doc View Source

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
Compression parameter selection
| Improve this Doc View Source

Next_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
jpeg_write_scanlines(Byte[][], Int32)
| Improve this Doc View Source

Num_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.

| Improve this Doc View Source

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

true causes the compressor to compute optimal Huffman coding tables for the image. This requires an extra pass over the data and therefore costs a good deal of space and time. The default is false, which tells the compressor to use the supplied or default Huffman tables. In most cases optimal tables save only a few percent of file size compared to the default tables.

Remarks

When this is true, you need not supply Huffman tables at all, and any you do supply will be overwritten.

See Also
Compression parameter selection
| Improve this Doc View Source

Quant_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.

| Improve this Doc View Source

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

true if you will be supplying raw data; otherwise, false.

Remarks

Default value: false

See Also
jpeg_write_raw_data(Byte[][][], Int32)
| Improve this Doc View Source

Restart_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
Restart_interval
Compression parameter selection
| Improve this Doc View Source

Restart_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
Restart_in_rows
Compression parameter selection
| Improve this Doc View Source

Smoothing_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
Compression parameter selection
| Improve this Doc View Source

Write_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 true an Adobe APP14 marker is emitted; false, otherwise.

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
Compression parameter selection
| Improve this Doc View Source

Write_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

true if JFIF APP0 marker is emitted; otherwise, false.

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
JFIF_major_version
Compression parameter selection
| Improve this Doc View Source

X_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
Density_unit
Y_density
| Improve this Doc View Source

Y_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
Density_unit
X_density

Methods

| Improve this Doc View Source

jpeg_abort_compress()

Abort processing of a JPEG compression operation.

Declaration
public void jpeg_abort_compress()
| Improve this Doc View Source

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 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.

System.Int32 scale_factor

Multiplier for values in basic_table.

System.Boolean force_baseline

Defines range of values in basic_table. If true - 1..255, otherwise - 1..65535.

See Also
Compression parameter selection
| Improve this Doc View Source

jpeg_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
Compression parameter selection
| Improve this Doc View Source

jpeg_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 true then baseline version is forced.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
Compression parameter selection
| Improve this Doc View Source

jpeg_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
Compression parameter selection
Special color spaces
| Improve this Doc View Source

jpeg_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
Compression parameter selection
| Improve this Doc View Source

jpeg_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 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.

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
Compression parameter selection
| Improve this Doc View Source

jpeg_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 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.

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
Compression parameter selection
| Improve this Doc View Source

jpeg_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
Compression parameter selection
| Improve this Doc View Source

jpeg_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
jpeg_suppress_tables(Boolean)
jpeg_write_tables()
Compression details
| Improve this Doc View Source

jpeg_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
Compression details
| Improve this Doc View Source

jpeg_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 true then suppress tables; otherwise unsuppress.

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.

| Improve this Doc View Source

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 jpeg_write_coefficients is called; indeed, the virtual arrays typically will be realized during this routine and filled afterwards.

Remarks

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

| Improve this Doc View Source

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
jpeg_write_m_header(Int32, Int32)
| Improve this Doc View Source

jpeg_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
jpeg_write_m_byte(Byte)
jpeg_write_marker(Int32, Byte[])
Special markers
| Improve this Doc View Source

jpeg_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
Special markers
JPEG_MARKER
| Improve this Doc View Source

jpeg_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.

| Improve this Doc View Source

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.
This should be less than the supplied num_lines only in case that the data destination module has requested suspension of the compressor, or if more than image_height scanlines are passed in.

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
Compression details
| Improve this Doc View Source

jpeg_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.

See Also

jpeg_decompress_struct
  • Improve this Doc
  • View Source
Back to top Generated by DocFX