BitMiracle.LibJpeg.Classic.Internal.JpegUtils.jround_up C# (CSharp) Method

jround_up() public static method

Compute a rounded up to next multiple of b, ie, ceil(a/b)*b Assumes a >= 0, b > 0
public static jround_up ( int a, int b ) : int
a int
b int
return int
        public static int jround_up(int a, int b)
        {
            a += b - 1;
            return a - (a % b);
        }

Usage Example

        private int m_next_row;                   /* index of next row to fill/empty in strip */

        /// <summary>
        /// Initialize postprocessing controller.
        /// </summary>
        public jpeg_d_post_controller(jpeg_decompress_struct cinfo, bool need_full_buffer)
        {
            m_cinfo = cinfo;

            /* Create the quantization buffer, if needed */
            if (cinfo.m_quantize_colors)
            {
                /* The buffer strip height is max_v_samp_factor, which is typically
                 * an efficient number of rows for upsampling to return.
                 * (In the presence of output rescaling, we might want to be smarter?)
                 */
                m_strip_height = cinfo.m_max_v_samp_factor;

                if (need_full_buffer)
                {
                    /* Two-pass color quantization: need full-image storage. */
                    /* We round up the number of rows to a multiple of the strip height. */
                    m_whole_image = jpeg_common_struct.CreateSamplesArray(
                        cinfo.m_output_width * cinfo.m_out_color_components,
                        JpegUtils.jround_up(cinfo.m_output_height, m_strip_height));
                    m_whole_image.ErrorProcessor = cinfo;
                }
                else
                {
                    /* One-pass color quantization: just make a strip buffer. */
                    m_buffer = jpeg_common_struct.AllocJpegSamples(
                        cinfo.m_output_width * cinfo.m_out_color_components, m_strip_height);
                }
            }
        }
All Usage Examples Of BitMiracle.LibJpeg.Classic.Internal.JpegUtils::jround_up