本文整理汇总了C#中BitMiracle.LibJpeg.Classic.Internal.ComponentBuffer.SetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ComponentBuffer.SetBuffer方法的具体用法?C# ComponentBuffer.SetBuffer怎么用?C# ComponentBuffer.SetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMiracle.LibJpeg.Classic.Internal.ComponentBuffer
的用法示例。
在下文中一共展示了ComponentBuffer.SetBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: my_upsampler
public my_upsampler(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
m_need_context_rows = false; /* until we find out differently */
if (cinfo.m_CCIR601_sampling) /* this isn't supported */
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CCIR601_NOTIMPL);
/* jpeg_d_main_controller doesn't support context rows when min_DCT_scaled_size = 1,
* so don't ask for it.
*/
bool do_fancy = cinfo.m_do_fancy_upsampling && cinfo.m_min_DCT_scaled_size > 1;
/* Verify we can handle the sampling factors, select per-component methods,
* and create storage as needed.
*/
for (int ci = 0; ci < cinfo.m_num_components; ci++)
{
jpeg_component_info componentInfo = cinfo.Comp_info[ci];
/* Compute size of an "input group" after IDCT scaling. This many samples
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
*/
int h_in_group = (componentInfo.H_samp_factor * componentInfo.DCT_scaled_size) / cinfo.m_min_DCT_scaled_size;
int v_in_group = (componentInfo.V_samp_factor * componentInfo.DCT_scaled_size) / cinfo.m_min_DCT_scaled_size;
int h_out_group = cinfo.m_max_h_samp_factor;
int v_out_group = cinfo.m_max_v_samp_factor;
/* save for use later */
m_rowgroup_height[ci] = v_in_group;
bool need_buffer = true;
if (!componentInfo.component_needed)
{
/* Don't bother to upsample an uninteresting component. */
m_upsampleMethods[ci] = ComponentUpsampler.noop_upsampler;
need_buffer = false;
}
else if (h_in_group == h_out_group && v_in_group == v_out_group)
{
/* Fullsize components can be processed without any work. */
m_upsampleMethods[ci] = ComponentUpsampler.fullsize_upsampler;
need_buffer = false;
}
else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group)
{
/* Special cases for 2h1v upsampling */
if (do_fancy && componentInfo.downsampled_width > 2)
m_upsampleMethods[ci] = ComponentUpsampler.h2v1_fancy_upsampler;
else
m_upsampleMethods[ci] = ComponentUpsampler.h2v1_upsampler;
}
else if (h_in_group * 2 == h_out_group && v_in_group * 2 == v_out_group)
{
/* Special cases for 2h2v upsampling */
if (do_fancy && componentInfo.downsampled_width > 2)
{
m_upsampleMethods[ci] = ComponentUpsampler.h2v2_fancy_upsampler;
m_need_context_rows = true;
}
else
{
m_upsampleMethods[ci] = ComponentUpsampler.h2v2_upsampler;
}
}
else if ((h_out_group % h_in_group) == 0 && (v_out_group % v_in_group) == 0)
{
/* Generic integral-factors upsampling method */
m_upsampleMethods[ci] = ComponentUpsampler.int_upsampler;
m_h_expand[ci] = (byte) (h_out_group / h_in_group);
m_v_expand[ci] = (byte) (v_out_group / v_in_group);
}
else
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_FRACT_SAMPLE_NOTIMPL);
if (need_buffer)
{
ComponentBuffer cb = new ComponentBuffer();
cb.SetBuffer(jpeg_common_struct.AllocJpegSamples(JpegUtils.jround_up(cinfo.m_output_width,
cinfo.m_max_h_samp_factor), cinfo.m_max_v_samp_factor), null, 0);
m_color_buf[ci] = cb;
}
}
}