C# Class BitMiracle.LibJpeg.Classic.Internal.jpeg_color_converter

Colorspace conversion
Exibir arquivo Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
jpeg_color_converter ( jpeg_compress_struct cinfo )
start_pass ( ) : void

Private Methods

Method Description
FIX ( double x ) : int
cmyk_ycck_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void

Convert some rows of samples to the JPEG colorspace. This version handles Adobe-style CMYK->YCCK conversion, where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same conversion as above, while passing K (black) unchanged. We assume rgb_ycc_start has been called.

grayscale_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void

Convert some rows of samples to the JPEG colorspace. This version handles grayscale output with no conversion. The source can be either plain grayscale or YCC (since Y == gray).

null_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void

Convert some rows of samples to the JPEG colorspace. This version handles multi-component colorspaces without conversion. We assume input_components == num_components.

rgb_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void
rgb_gray_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void

Convert some rows of samples to the JPEG colorspace. This version handles RGB->grayscale conversion, which is the same as the RGB->Y portion of RGB->YCbCr. We assume rgb_ycc_start has been called (we only use the Y tables).

rgb_rgb1_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void
rgb_ycc_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void

RGB -> YCbCr conversion: most common case YCbCr is defined per CCIR 601-1, except that Cb and Cr are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. The conversion equations to be implemented are therefore Y = 0.29900 * R + 0.58700 * G + 0.11400 * B Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) To avoid floating-point arithmetic, we represent the fractional constants as integers scaled up by 2^16 (about 4 digits precision); we have to divide the products by 2^16, with appropriate rounding, to get the correct answer. For even more speed, we avoid doing any multiplications in the inner loop by precalculating the constants times R,G,B for all possible values. For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); for 12-bit samples it is still acceptable. It's not very reasonable for 16-bit samples, but if you want lossless storage you shouldn't be changing colorspace anyway. The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included in the tables to save adding them separately in the inner loop.

rgb_ycc_start ( ) : void

Initialize for RGB->YCC colorspace conversion.

Method Details

jpeg_color_converter() public method

public jpeg_color_converter ( jpeg_compress_struct cinfo )
cinfo jpeg_compress_struct

start_pass() public method

public start_pass ( ) : void
return void