本文整理汇总了C#中jpeg_decompress_struct类的典型用法代码示例。如果您正苦于以下问题:C# jpeg_decompress_struct类的具体用法?C# jpeg_decompress_struct怎么用?C# jpeg_decompress_struct使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
jpeg_decompress_struct类属于命名空间,在下文中一共展示了jpeg_decompress_struct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: jpeg_d_coef_controller
public jpeg_d_coef_controller(jpeg_decompress_struct cinfo, bool need_full_buffer)
{
m_cinfo = cinfo;
/* Create the coefficient buffer. */
if (need_full_buffer)
{
/* Allocate a full-image virtual array for each component, */
/* padded to a multiple of samp_factor DCT blocks in each direction. */
/* Note we ask for a pre-zeroed array. */
for (int ci = 0; ci < cinfo.m_num_components; ci++)
{
m_whole_image[ci] = jpeg_common_struct.CreateBlocksArray(
JpegUtils.jround_up(cinfo.Comp_info[ci].Width_in_blocks, cinfo.Comp_info[ci].H_samp_factor),
JpegUtils.jround_up(cinfo.Comp_info[ci].height_in_blocks, cinfo.Comp_info[ci].V_samp_factor));
m_whole_image[ci].ErrorProcessor = cinfo;
}
m_useDummyConsumeData = false;
m_decompressor = DecompressorType.Ordinary;
m_coef_arrays = m_whole_image; /* link to virtual arrays */
}
else
{
/* We only need a single-MCU buffer. */
for (int i = 0; i < JpegConstants.D_MAX_BLOCKS_IN_MCU; i++)
m_MCU_buffer[i] = new JBLOCK();
m_useDummyConsumeData = true;
m_decompressor = DecompressorType.OnePass;
m_coef_arrays = null; /* flag for no virtual arrays */
}
}
示例2: jpeg_d_post_controller
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);
}
}
}
示例3: savable_state
private savable_state m_saved = new savable_state(); /* Other state at start of MCU */
#endregion Fields
#region Constructors
public huff_entropy_decoder(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
/* Mark tables unallocated */
for (int i = 0; i < JpegConstants.NUM_HUFF_TBLS; i++)
m_dc_derived_tbls[i] = m_ac_derived_tbls[i] = null;
}
示例4: jpeg_input_controller
private bool m_eoi_reached; /* True when EOI has been consumed */
/// <summary>
/// Initialize the input controller module.
/// This is called only once, when the decompression object is created.
/// </summary>
public jpeg_input_controller(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
/* Initialize state: can't use reset_input_controller since we don't
* want to try to reset other modules yet.
*/
m_inheaders = true;
}
示例5: savable_state
private savable_state m_saved = new savable_state(); /* Other state at start of MCU */
#endregion Fields
#region Constructors
public phuff_entropy_decoder(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
/* Mark derived tables unallocated */
for (int i = 0; i < JpegConstants.NUM_HUFF_TBLS; i++)
m_derived_tbls[i] = null;
/* Create progression status table */
cinfo.m_coef_bits = new int[cinfo.m_num_components][];
for (int i = 0; i < cinfo.m_num_components; i++)
cinfo.m_coef_bits[i] = new int[JpegConstants.DCTSIZE2];
for (int ci = 0; ci < cinfo.m_num_components; ci++)
{
for (int i = 0; i < JpegConstants.DCTSIZE2; i++)
cinfo.m_coef_bits[ci][i] = -1;
}
}
示例6: my_merged_upsampler
private int m_rows_to_go; /* counts rows remaining in image */
public my_merged_upsampler(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
m_need_context_rows = false;
m_out_row_width = cinfo.m_output_width * cinfo.m_out_color_components;
if (cinfo.m_max_v_samp_factor == 2)
{
m_use_2v_upsample = true;
/* Allocate a spare row buffer */
m_spare_row = new byte[m_out_row_width];
}
else
{
m_use_2v_upsample = false;
}
build_ycc_rgb_table();
}
示例7: jpeg_marker_reader
private int m_bytes_read; /* data bytes read so far in marker */
/* Note: cur_marker is not linked into marker_list until it's all read. */
/// <summary>
/// Initialize the marker reader module.
/// This is called only once, when the decompression object is created.
/// </summary>
public jpeg_marker_reader(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
/* Initialize COM/APPn processing.
* By default, we examine and then discard APP0 and APP14,
* but simply discard COM and all other APPn.
*/
m_process_COM = skip_variable;
for (int i = 0; i < 16; i++)
{
m_process_APPn[i] = skip_variable;
m_length_limit_APPn[i] = 0;
}
m_process_APPn[0] = get_interesting_appn;
m_process_APPn[14] = get_interesting_appn;
/* Reset marker processing state */
reset_marker_reader();
}
示例8: my_source_mgr
private bool m_start_of_file; /* have we gotten any data yet? */
/// <summary>
/// Initialize source - called by jpeg_read_header
/// before any data is actually read.
/// </summary>
public my_source_mgr(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
m_buffer = new byte[INPUT_BUF_SIZE];
}
示例9: my_2pass_cquantizer
private int[] m_error_limiter; /* table for clamping the applied error */
/// <summary>
/// Module initialization routine for 2-pass color quantization.
/// </summary>
public my_2pass_cquantizer(jpeg_decompress_struct cinfo)
{
m_cinfo = cinfo;
/* Make sure jdmaster didn't give me a case I can't handle */
if (cinfo.m_out_color_components != 3)
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_NOTIMPL);
/* Allocate the histogram/inverse colormap storage */
m_histogram = new ushort[HIST_C0_ELEMS][];
for (int i = 0; i < HIST_C0_ELEMS; i++)
m_histogram[i] = new ushort[HIST_C1_ELEMS * HIST_C2_ELEMS];
m_needs_zeroed = true; /* histogram is garbage now */
/* Allocate storage for the completed colormap, if required.
* We do this now since it is FAR storage and may affect
* the memory manager's space calculations.
*/
if (cinfo.m_enable_2pass_quant)
{
/* Make sure color count is acceptable */
int desired_local = cinfo.m_desired_number_of_colors;
/* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */
if (desired_local < 8)
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_QUANT_FEW_COLORS, 8);
/* Make sure colormap indexes can be represented by JSAMPLEs */
if (desired_local > MAXNUMCOLORS)
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
m_sv_colormap = jpeg_common_struct.AllocJpegSamples(desired_local, 3);
m_desired = desired_local;
}
/* Only F-S dithering or no dithering is supported. */
/* If user asks for ordered dither, give him F-S. */
if (cinfo.m_dither_mode != J_DITHER_MODE.JDITHER_NONE)
cinfo.m_dither_mode = J_DITHER_MODE.JDITHER_FS;
/* Allocate Floyd-Steinberg workspace if necessary.
* This isn't really needed until pass 2, but again it is FAR storage.
* Although we will cope with a later change in dither_mode,
* we do not promise to honor max_memory_to_use if dither_mode changes.
*/
if (cinfo.m_dither_mode == J_DITHER_MODE.JDITHER_FS)
{
m_fserrors = new short[(cinfo.m_output_width + 2) * 3];
/* Might as well create the error-limiting table too. */
init_error_limit();
}
}
示例10: term_source
// Terminate an input source.
private static void term_source(ref jpeg_decompress_struct cinfo)
{
// Nothing to do here.
}
示例11: fill_input_buffer_type
// Convert a stream into a source manager.
public static void StreamToSourceManager
(ref jpeg_decompress_struct cinfo, Stream stream,
byte[] prime, int primeLen)
{
// Allocate a state structure and store it in "cinfo".
IntPtr buf = Marshal.AllocHGlobal(4096);
StreamState state = new StreamState();
state.buf = buf;
state.buffer = new byte [4096];
state.stream = stream;
cinfo.client_data = (IntPtr)(GCHandle.Alloc(state));
// We prime the input buffer with the JPEG magic number
// if some higher-level process has already read it.
int len;
if(prime != null)
{
len = primeLen;
Marshal.Copy(prime, 0, buf, len);
}
else
{
len = 0;
}
// Create the managed version of "jpeg_source_mgr".
jpeg_source_mgr mgr = new jpeg_source_mgr();
mgr.next_input_byte = buf;
mgr.bytes_in_buffer = (size_t)len;
mgr.init_source = new init_source_type(init_source);
mgr.fill_input_buffer =
new fill_input_buffer_type(fill_input_buffer);
mgr.skip_input_data =
new skip_input_data_type(skip_input_data);
mgr.resync_to_restart =
new resync_to_restart_type(jpeg_resync_to_restart);
mgr.term_source =
new term_source_type(term_source);
// Convert it into the unmanaged version and store it.
#if __CSCC__
IntPtr umgr = Marshal.AllocHGlobal(sizeof(jpeg_source_mgr));
Marshal.StructureToPtr(mgr, umgr, false);
cinfo.src = (jpeg_source_mgr *)umgr;
#endif
}
示例12: IntPtr
// Skip data in an input stream.
private static void skip_input_data
(ref jpeg_decompress_struct cinfo, Long num_bytes)
{
#if __CSCC__
jpeg_source_mgr *src = cinfo.src;
int num = (int)num_bytes;
if(num > 0)
{
while(num > (int)(src->bytes_in_buffer))
{
num -= (int)(src->bytes_in_buffer);
fill_input_buffer(ref cinfo);
}
src->next_input_byte =
new IntPtr((src->next_input_byte.ToInt64()) + num);
src->bytes_in_buffer =
(size_t)(((int)(src->bytes_in_buffer)) - num);
}
#endif
}
示例13: 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;
}
}
}
示例14: examine_app14
/// <summary>
/// Examine first few bytes from an APP14.
/// Take appropriate action if it is an Adobe marker.
/// datalen is # of bytes at data[], remaining is length of rest of marker data.
/// </summary>
private static void examine_app14(jpeg_decompress_struct cinfo, byte[] data, int datalen, int remaining)
{
if (datalen >= APP14_DATA_LEN &&
data[0] == 0x41 &&
data[1] == 0x64 &&
data[2] == 0x6F &&
data[3] == 0x62 &&
data[4] == 0x65)
{
/* Found Adobe APP14 marker */
int version = (data[5] << 8) + data[6];
int flags0 = (data[7] << 8) + data[8];
int flags1 = (data[9] << 8) + data[10];
int transform = data[11];
cinfo.TRACEMS(1, J_MESSAGE_CODE.JTRC_ADOBE, version, flags0, flags1, transform);
cinfo.m_saw_Adobe_marker = true;
cinfo.m_Adobe_transform = (byte) transform;
}
else
{
/* Start of APP14 does not match "Adobe", or too short */
cinfo.TRACEMS(1, J_MESSAGE_CODE.JTRC_APP14, datalen + remaining);
}
}
示例15: get_interesting_appn
/// <summary>
/// Process an APP0 or APP14 marker without saving it
/// </summary>
private static bool get_interesting_appn(jpeg_decompress_struct cinfo)
{
int length;
if (!cinfo.m_src.GetTwoBytes(out length))
return false;
length -= 2;
/* get the interesting part of the marker data */
int numtoread = 0;
if (length >= APPN_DATA_LEN)
numtoread = APPN_DATA_LEN;
else if (length > 0)
numtoread = length;
byte[] b = new byte[APPN_DATA_LEN];
for (int i = 0; i < numtoread; i++)
{
int temp = 0;
if (!cinfo.m_src.GetByte(out temp))
return false;
b[i] = (byte) temp;
}
length -= numtoread;
/* process it */
switch ((JPEG_MARKER)cinfo.m_unread_marker)
{
case JPEG_MARKER.APP0:
examine_app0(cinfo, b, numtoread, length);
break;
case JPEG_MARKER.APP14:
examine_app14(cinfo, b, numtoread, length);
break;
default:
/* can't get here unless jpeg_save_markers chooses wrong processor */
cinfo.ERREXIT(J_MESSAGE_CODE.JERR_UNKNOWN_MARKER, cinfo.m_unread_marker);
break;
}
/* skip any remaining data -- could be lots */
if (length > 0)
cinfo.m_src.skip_input_data(length);
return true;
}