亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? jquant1.c

?? WinCE開(kāi)發(fā)技巧與實(shí)例的配套源碼
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/*
 * jquant1.c
 *
 * Copyright (C) 1991-1996, Thomas G. Lane.
 * This file is part of the Independent JPEG Group's software.
 * For conditions of distribution and use, see the accompanying README file.
 *
 * This file contains 1-pass color quantization (color mapping) routines.
 * These routines provide mapping to a fixed color map using equally spaced
 * color values.  Optional Floyd-Steinberg or ordered dithering is available.
 */

#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"

#ifdef QUANT_1PASS_SUPPORTED


/*
 * The main purpose of 1-pass quantization is to provide a fast, if not very
 * high quality, colormapped output capability.  A 2-pass quantizer usually
 * gives better visual quality; however, for quantized grayscale output this
 * quantizer is perfectly adequate.  Dithering is highly recommended with this
 * quantizer, though you can turn it off if you really want to.
 *
 * In 1-pass quantization the colormap must be chosen in advance of seeing the
 * image.  We use a map consisting of all combinations of Ncolors[i] color
 * values for the i'th component.  The Ncolors[] values are chosen so that
 * their product, the total number of colors, is no more than that requested.
 * (In most cases, the product will be somewhat less.)
 *
 * Since the colormap is orthogonal, the representative value for each color
 * component can be determined without considering the other components;
 * then these indexes can be combined into a colormap index by a standard
 * N-dimensional-array-subscript calculation.  Most of the arithmetic involved
 * can be precalculated and stored in the lookup table colorindex[].
 * colorindex[i][j] maps pixel value j in component i to the nearest
 * representative value (grid plane) for that component; this index is
 * multiplied by the array stride for component i, so that the
 * index of the colormap entry closest to a given pixel value is just
 *    sum( colorindex[component-number][pixel-component-value] )
 * Aside from being fast, this scheme allows for variable spacing between
 * representative values with no additional lookup cost.
 *
 * If gamma correction has been applied in color conversion, it might be wise
 * to adjust the color grid spacing so that the representative colors are
 * equidistant in linear space.  At this writing, gamma correction is not
 * implemented by jdcolor, so nothing is done here.
 */


/* Declarations for ordered dithering.
 *
 * We use a standard 16x16 ordered dither array.  The basic concept of ordered
 * dithering is described in many references, for instance Dale Schumacher's
 * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991).
 * In place of Schumacher's comparisons against a "threshold" value, we add a
 * "dither" value to the input pixel and then round the result to the nearest
 * output value.  The dither value is equivalent to (0.5 - threshold) times
 * the distance between output values.  For ordered dithering, we assume that
 * the output colors are equally spaced; if not, results will probably be
 * worse, since the dither may be too much or too little at a given point.
 *
 * The normal calculation would be to form pixel value + dither, range-limit
 * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual.
 * We can skip the separate range-limiting step by extending the colorindex
 * table in both directions.
 */

#define ODITHER_SIZE  16	/* dimension of dither matrix */
/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */
#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE)	/* # cells in matrix */
#define ODITHER_MASK  (ODITHER_SIZE-1) /* mask for wrapping around counters */

typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE];
typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE];

static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {
  /* Bayer's order-4 dither array.  Generated by the code given in
   * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I.
   * The values in this array must range from 0 to ODITHER_CELLS-1.
   */
  {   0,192, 48,240, 12,204, 60,252,  3,195, 51,243, 15,207, 63,255 },
  { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
  {  32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
  { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
  {   8,200, 56,248,  4,196, 52,244, 11,203, 59,251,  7,199, 55,247 },
  { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
  {  40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
  { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
  {   2,194, 50,242, 14,206, 62,254,  1,193, 49,241, 13,205, 61,253 },
  { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
  {  34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
  { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
  {  10,202, 58,250,  6,198, 54,246,  9,201, 57,249,  5,197, 53,245 },
  { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
  {  42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
  { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
};


/* Declarations for Floyd-Steinberg dithering.
 *
 * Errors are accumulated into the array fserrors[], at a resolution of
 * 1/16th of a pixel count.  The error at a given pixel is propagated
 * to its not-yet-processed neighbors using the standard F-S fractions,
 *		...	(here)	7/16
 *		3/16	5/16	1/16
 * We work left-to-right on even rows, right-to-left on odd rows.
 *
 * We can get away with a single array (holding one row's worth of errors)
 * by using it to store the current row's errors at pixel columns not yet
 * processed, but the next row's errors at columns already processed.  We
 * need only a few extra variables to hold the errors immediately around the
 * current column.  (If we are lucky, those variables are in registers, but
 * even if not, they're probably cheaper to access than array elements are.)
 *
 * The fserrors[] array is indexed [component#][position].
 * We provide (#columns + 2) entries per component; the extra entry at each
 * end saves us from special-casing the first and last pixels.
 *
 * Note: on a wide image, we might not have enough room in a PC's near data
 * segment to hold the error array; so it is allocated with alloc_large.
 */

#if BITS_IN_JSAMPLE == 8
typedef INT16 FSERROR;		/* 16 bits should be enough */
typedef int LOCFSERROR;		/* use 'int' for calculation temps */
#else
typedef INT32 FSERROR;		/* may need more than 16 bits */
typedef INT32 LOCFSERROR;	/* be sure calculation temps are big enough */
#endif

typedef FSERROR FAR *FSERRPTR;	/* pointer to error array (in FAR storage!) */


/* Private subobject */

#define MAX_Q_COMPS 4		/* max components I can handle */

typedef struct {
  struct jpeg_color_quantizer pub; /* public fields */

  /* Initially allocated colormap is saved here */
  JSAMPARRAY sv_colormap;	/* The color map as a 2-D pixel array */
  int sv_actual;		/* number of entries in use */

  JSAMPARRAY colorindex;	/* Precomputed mapping for speed */
  /* colorindex[i][j] = index of color closest to pixel value j in component i,
   * premultiplied as described above.  Since colormap indexes must fit into
   * JSAMPLEs, the entries of this array will too.
   */
  boolean is_padded;		/* is the colorindex padded for odither? */

  int Ncolors[MAX_Q_COMPS];	/* # of values alloced to each component */

  /* Variables for ordered dithering */
  int row_index;		/* cur row's vertical index in dither matrix */
  ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */

  /* Variables for Floyd-Steinberg dithering */
  FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */
  boolean on_odd_row;		/* flag to remember which row we are on */
} my_cquantizer;

typedef my_cquantizer * my_cquantize_ptr;


/*
 * Policy-making subroutines for create_colormap and create_colorindex.
 * These routines determine the colormap to be used.  The rest of the module
 * only assumes that the colormap is orthogonal.
 *
 *  * select_ncolors decides how to divvy up the available colors
 *    among the components.
 *  * output_value defines the set of representative values for a component.
 *  * largest_input_value defines the mapping from input values to
 *    representative values for a component.
 * Note that the latter two routines may impose different policies for
 * different components, though this is not currently done.
 */


LOCAL(int)
select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
/* Determine allocation of desired colors to components, */
/* and fill in Ncolors[] array to indicate choice. */
/* Return value is total number of colors (product of Ncolors[] values). */
{
  int nc = cinfo->out_color_components; /* number of color components */
  int max_colors = cinfo->desired_number_of_colors;
  int total_colors, iroot, i, j;
  boolean changed;
  long temp;
  static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE };

  /* We can allocate at least the nc'th root of max_colors per component. */
  /* Compute floor(nc'th root of max_colors). */
  iroot = 1;
  do {
    iroot++;
    temp = iroot;		/* set temp = iroot ** nc */
    for (i = 1; i < nc; i++)
      temp *= iroot;
  } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */
  iroot--;			/* now iroot = floor(root) */

  /* Must have at least 2 color values per component */
  if (iroot < 2)
    ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp);

  /* Initialize to iroot color values for each component */
  total_colors = 1;
  for (i = 0; i < nc; i++) {
    Ncolors[i] = iroot;
    total_colors *= iroot;
  }
  /* We may be able to increment the count for one or more components without
   * exceeding max_colors, though we know not all can be incremented.
   * Sometimes, the first component can be incremented more than once!
   * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.)
   * In RGB colorspace, try to increment G first, then R, then B.
   */
  do {
    changed = FALSE;
    for (i = 0; i < nc; i++) {
      j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i);
      /* calculate new total_colors if Ncolors[j] is incremented */
      temp = total_colors / Ncolors[j];
      temp *= Ncolors[j]+1;	/* done in long arith to avoid oflo */
      if (temp > (long) max_colors)
	break;			/* won't fit, done with this pass */
      Ncolors[j]++;		/* OK, apply the increment */
      total_colors = (int) temp;
      changed = TRUE;
    }
  } while (changed);

  return total_colors;
}


LOCAL(int)
output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return j'th output value, where j will range from 0 to maxj */
/* The output values must fall in 0..MAXJSAMPLE in increasing order */
{
  /* We always provide values 0 and MAXJSAMPLE for each component;
   * any additional values are equally spaced between these limits.
   * (Forcing the upper and lower values to the limits ensures that
   * dithering can't produce a color outside the selected gamut.)
   */
  return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj);
}


LOCAL(int)
largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return largest input value that should map to j'th output value */
/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
{
  /* Breakpoints are halfway between values returned by output_value */
  return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj));
}


/*
 * Create the colormap.
 */

LOCAL(void)
create_colormap (j_decompress_ptr cinfo)
{
  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
  JSAMPARRAY colormap;		/* Created colormap */
  int total_colors;		/* Number of distinct output colors */
  int i,j,k, nci, blksize, blkdist, ptr, val;

  /* Select number of colors for each component */
  total_colors = select_ncolors(cinfo, cquantize->Ncolors);

  /* Report selected color counts */
  if (cinfo->out_color_components == 3)
    TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS,
	     total_colors, cquantize->Ncolors[0],

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区精品在线播放| 日韩国产精品久久| 天天影视涩香欲综合网| 成人自拍视频在线| 日韩午夜激情免费电影| 亚洲久本草在线中文字幕| 国产一区二区不卡老阿姨| 欧美日韩精品福利| 日韩一区在线免费观看| 国产米奇在线777精品观看| 欧美高清hd18日本| 亚洲高清中文字幕| 一本色道久久综合亚洲91| 国产欧美日韩另类一区| 久久精品理论片| 91精品国产免费| 日日摸夜夜添夜夜添精品视频| 成人av在线看| 日本一区二区三级电影在线观看| 美国十次了思思久久精品导航| 欧美日韩一卡二卡| 亚洲国产欧美在线| 在线观看一区不卡| 亚洲最大色网站| 91网站最新网址| 亚洲精品视频在线看| 91亚洲精华国产精华精华液| 欧美国产一区在线| 成人在线一区二区三区| 久久久久国产免费免费| 国产乱人伦偷精品视频不卡| 精品国产99国产精品| 韩国在线一区二区| www亚洲一区| 国产精品白丝jk黑袜喷水| 欧美激情一区在线| 97久久久精品综合88久久| 亚洲精品中文在线观看| 欧美少妇性性性| 日日摸夜夜添夜夜添亚洲女人| 6080午夜不卡| 精品在线亚洲视频| 久久亚洲综合av| 成人av在线播放网址| 亚洲视频在线一区二区| 欧美三级韩国三级日本三斤| 无吗不卡中文字幕| 欧美一级欧美三级| 国产一区二区美女| 亚洲欧美经典视频| 欧美精品视频www在线观看| 理论片日本一区| 国产精品女人毛片| 欧美亚洲综合网| 国产一区三区三区| 亚洲人成精品久久久久久| 欧美视频在线一区| 国产一区二区不卡在线| 亚洲免费观看高清完整| 91精品国产综合久久久久久久| 久久精品免费观看| 国产精品每日更新在线播放网址| 欧美三日本三级三级在线播放| 久久国产尿小便嘘嘘| 亚洲人成网站色在线观看| 3d成人h动漫网站入口| 成人免费观看视频| 日本欧美久久久久免费播放网| 国产蜜臀av在线一区二区三区| 欧美亚洲日本一区| 国产69精品久久777的优势| 亚洲图片欧美色图| 国产欧美日韩精品一区| 欧美日韩黄视频| 国产白丝精品91爽爽久久| 五月天婷婷综合| 国产欧美日韩综合| 日韩精品一区二区三区在线观看 | 久久蜜桃av一区精品变态类天堂| 成年人午夜久久久| 乱一区二区av| 亚洲综合av网| 国产精品久久久久久久第一福利| 欧美一二三四区在线| 91激情在线视频| 成人免费看黄yyy456| 久久国内精品视频| 全国精品久久少妇| 夜夜嗨av一区二区三区| 国产精品福利一区二区| 精品电影一区二区三区| 91精品国产综合久久福利软件 | 成人午夜伦理影院| 精品一区二区综合| 蜜桃91丨九色丨蝌蚪91桃色| 亚洲一区二区三区中文字幕在线| 国产精品色眯眯| 日本一区二区三区电影| 久久夜色精品国产欧美乱极品| 制服.丝袜.亚洲.中文.综合| 欧美在线观看视频一区二区三区| 成+人+亚洲+综合天堂| 国产成人免费9x9x人网站视频| 美女高潮久久久| 美腿丝袜一区二区三区| 日本免费在线视频不卡一不卡二| 亚洲国产精品精华液网站| 亚洲女爱视频在线| 亚洲美女一区二区三区| 亚洲精品日韩综合观看成人91| 国产丝袜在线精品| 国产精品丝袜91| 亚洲天堂网中文字| 亚洲你懂的在线视频| 亚洲综合在线观看视频| 亚洲一二三专区| 亚洲国产精品天堂| 日韩黄色免费电影| 久久精品国产免费| 国产91富婆露脸刺激对白| 成人午夜激情视频| 色综合久久天天综合网| 在线观看亚洲专区| 777午夜精品免费视频| 日韩欧美精品在线视频| 久久嫩草精品久久久久| 亚洲国产电影在线观看| 一区二区视频免费在线观看| 亚洲高清中文字幕| 国产最新精品免费| 成人教育av在线| 欧美中文字幕亚洲一区二区va在线| 91福利国产成人精品照片| 91精品国产免费| 国产校园另类小说区| 亚洲乱码中文字幕综合| 日本亚洲欧美天堂免费| 国产中文一区二区三区| 91亚洲精品乱码久久久久久蜜桃| 欧美性色黄大片手机版| 精品少妇一区二区三区视频免付费 | 91超碰这里只有精品国产| 欧美成人一区二区三区片免费| 久久综合九色综合97_久久久| 国产精品视频一二三区| 亚洲国产精品一区二区www在线 | 日本视频中文字幕一区二区三区| 久久精品免费观看| 91蜜桃传媒精品久久久一区二区| 欧美亚洲一区二区在线| 精品对白一区国产伦| 亚洲综合丁香婷婷六月香| 精品一区二区av| 欧美日韩在线一区二区| 久久久久久久网| 亚洲一区在线观看网站| 国产成人午夜99999| 欧美日韩夫妻久久| 欧美国产日韩亚洲一区| 免费在线观看一区二区三区| 夫妻av一区二区| 日韩亚洲欧美成人一区| 一区二区三区在线观看国产| 久久99精品国产麻豆婷婷洗澡| 91色在线porny| 日本一区二区视频在线观看| 婷婷国产v国产偷v亚洲高清| av不卡一区二区三区| 精品久久人人做人人爽| 午夜a成v人精品| 色婷婷综合久久久久中文一区二区| 欧美成人一级视频| 天堂成人国产精品一区| 91小视频在线免费看| 欧美国产精品中文字幕| 精品一区二区三区在线播放视频| 欧美日韩免费高清一区色橹橹| 国产精品毛片高清在线完整版| 精品亚洲aⅴ乱码一区二区三区| 欧美色欧美亚洲另类二区| 亚洲天堂免费看| 成人免费黄色大片| 国产日韩欧美激情| 韩国理伦片一区二区三区在线播放 | 国产三级一区二区三区| 久久99久久久久久久久久久| 5月丁香婷婷综合| 亚洲自拍与偷拍| 在线视频你懂得一区二区三区| 中文子幕无线码一区tr| 国产一区二区三区黄视频 | 欧美电影免费观看高清完整版| 亚洲国产日韩在线一区模特| 91女神在线视频| 亚洲人成亚洲人成在线观看图片| 99视频精品免费视频| 亚洲人成精品久久久久久| 色婷婷国产精品综合在线观看| 国产精品私房写真福利视频| 成人精品高清在线|