BitMiracle.LibJpeg.Classic.Internal.jpeg_color_converter.cmyk_ycck_convert C# (CSharp) Method

cmyk_ycck_convert() private method

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.
private cmyk_ycck_convert ( byte input_buf, int input_row, byte output_buf, int output_row, int num_rows ) : void
input_buf byte
input_row int
output_buf byte
output_row int
num_rows int
return void
        private void cmyk_ycck_convert(byte[][] input_buf, int input_row, byte[][][] output_buf, int output_row, int num_rows)
        {
            int num_cols = m_cinfo.m_image_width;
            for (int row = 0; row < num_rows; row++)
            {
                int columnOffset = 0;
                for (int col = 0; col < num_cols; col++)
                {
                    int r = JpegConstants.MAXJSAMPLE - input_buf[input_row + row][columnOffset];
                    int g = JpegConstants.MAXJSAMPLE - input_buf[input_row + row][columnOffset + 1];
                    int b = JpegConstants.MAXJSAMPLE - input_buf[input_row + row][columnOffset + 2];

                    /* K passes through as-is */
                    /* don't need GETJSAMPLE here */
                    output_buf[3][output_row][col] = input_buf[input_row + row][columnOffset + 3];
                    columnOffset += 4;

                    /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
                     * must be too; we do not need an explicit range-limiting operation.
                     * Hence the value being shifted is never negative, and we don't
                     * need the general RIGHT_SHIFT macro.
                     */
                    /* Y */
                    output_buf[0][output_row][col] = (byte)((m_rgb_ycc_tab[r + R_Y_OFF] + m_rgb_ycc_tab[g + G_Y_OFF] + m_rgb_ycc_tab[b + B_Y_OFF]) >> SCALEBITS);
                    /* Cb */
                    output_buf[1][output_row][col] = (byte)((m_rgb_ycc_tab[r + R_CB_OFF] + m_rgb_ycc_tab[g + G_CB_OFF] + m_rgb_ycc_tab[b + B_CB_OFF]) >> SCALEBITS);
                    /* Cr */
                    output_buf[2][output_row][col] = (byte)((m_rgb_ycc_tab[r + R_CR_OFF] + m_rgb_ycc_tab[g + G_CR_OFF] + m_rgb_ycc_tab[b + B_CR_OFF]) >> SCALEBITS);
                }

                output_row++;
            }
        }