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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wrgif.c

?? 一款最完整的工業組態軟源代碼
?? C
字號:
/*
 * wrgif.c
 *
 * Copyright (C) 1991-1997, 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 routines to write output images in GIF format.
 *
 **************************************************************************
 * NOTE: to avoid entanglements with Unisys' patent on LZW compression,   *
 * this code has been modified to output "uncompressed GIF" files.        *
 * There is no trace of the LZW algorithm in this file.                   *
 **************************************************************************
 *
 * These routines may need modification for non-Unix environments or
 * specialized applications.  As they stand, they assume output to
 * an ordinary stdio stream.
 */

/*
 * This code is loosely based on ppmtogif from the PBMPLUS distribution
 * of Feb. 1991.  That file contains the following copyright notice:
 *    Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>.
 *    Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al.
 *    Copyright (C) 1989 by Jef Poskanzer.
 *    Permission to use, copy, modify, and distribute this software and its
 *    documentation for any purpose and without fee is hereby granted, provided
 *    that the above copyright notice appear in all copies and that both that
 *    copyright notice and this permission notice appear in supporting
 *    documentation.  This software is provided "as is" without express or
 *    implied warranty.
 *
 * We are also required to state that
 *    "The Graphics Interchange Format(c) is the Copyright property of
 *    CompuServe Incorporated. GIF(sm) is a Service Mark property of
 *    CompuServe Incorporated."
 */

#include "cdjpeg.h"		/* Common decls for cjpeg/djpeg applications */

#ifdef GIF_SUPPORTED


/* Private version of data destination object */

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

  j_decompress_ptr cinfo;	/* back link saves passing separate parm */

  /* State for packing variable-width codes into a bitstream */
  int n_bits;			/* current number of bits/code */
  int maxcode;			/* maximum code, given n_bits */
  INT32 cur_accum;		/* holds bits not yet output */
  int cur_bits;			/* # of bits in cur_accum */

  /* State for GIF code assignment */
  int ClearCode;		/* clear code (doesn't change) */
  int EOFCode;			/* EOF code (ditto) */
  int code_counter;		/* counts output symbols */

  /* GIF data packet construction buffer */
  int bytesinpkt;		/* # of bytes in current packet */
  char packetbuf[256];		/* workspace for accumulating packet */

} gif_dest_struct;

typedef gif_dest_struct * gif_dest_ptr;

/* Largest value that will fit in N bits */
#define MAXCODE(n_bits)	((1 << (n_bits)) - 1)


/*
 * Routines to package finished data bytes into GIF data blocks.
 * A data block consists of a count byte (1..255) and that many data bytes.
 */

LOCAL(void)
flush_packet (gif_dest_ptr dinfo)
/* flush any accumulated data */
{
  if (dinfo->bytesinpkt > 0) {	/* never write zero-length packet */
    dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++;
    if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt)
	!= (size_t) dinfo->bytesinpkt)
      ERREXIT(dinfo->cinfo, JERR_FILE_WRITE);
    dinfo->bytesinpkt = 0;
  }
}


/* Add a character to current packet; flush to disk if necessary */
#define CHAR_OUT(dinfo,c)  \
	{ (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c);  \
	    if ((dinfo)->bytesinpkt >= 255)  \
	      flush_packet(dinfo);  \
	}


/* Routine to convert variable-width codes into a byte stream */

LOCAL(void)
output (gif_dest_ptr dinfo, int code)
/* Emit a code of n_bits bits */
/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */
{
  dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits;
  dinfo->cur_bits += dinfo->n_bits;

  while (dinfo->cur_bits >= 8) {
    CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF);
    dinfo->cur_accum >>= 8;
    dinfo->cur_bits -= 8;
  }
}


/* The pseudo-compression algorithm.
 *
 * In this module we simply output each pixel value as a separate symbol;
 * thus, no compression occurs.  In fact, there is expansion of one bit per
 * pixel, because we use a symbol width one bit wider than the pixel width.
 *
 * GIF ordinarily uses variable-width symbols, and the decoder will expect
 * to ratchet up the symbol width after a fixed number of symbols.
 * To simplify the logic and keep the expansion penalty down, we emit a
 * GIF Clear code to reset the decoder just before the width would ratchet up.
 * Thus, all the symbols in the output file will have the same bit width.
 * Note that emitting the Clear codes at the right times is a mere matter of
 * counting output symbols and is in no way dependent on the LZW patent.
 *
 * With a small basic pixel width (low color count), Clear codes will be
 * needed very frequently, causing the file to expand even more.  So this
 * simplistic approach wouldn't work too well on bilevel images, for example.
 * But for output of JPEG conversions the pixel width will usually be 8 bits
 * (129 to 256 colors), so the overhead added by Clear symbols is only about
 * one symbol in every 256.
 */

LOCAL(void)
compress_init (gif_dest_ptr dinfo, int i_bits)
/* Initialize pseudo-compressor */
{
  /* init all the state variables */
  dinfo->n_bits = i_bits;
  dinfo->maxcode = MAXCODE(dinfo->n_bits);
  dinfo->ClearCode = (1 << (i_bits - 1));
  dinfo->EOFCode = dinfo->ClearCode + 1;
  dinfo->code_counter = dinfo->ClearCode + 2;
  /* init output buffering vars */
  dinfo->bytesinpkt = 0;
  dinfo->cur_accum = 0;
  dinfo->cur_bits = 0;
  /* GIF specifies an initial Clear code */
  output(dinfo, dinfo->ClearCode);
}


LOCAL(void)
compress_pixel (gif_dest_ptr dinfo, int c)
/* Accept and "compress" one pixel value.
 * The given value must be less than n_bits wide.
 */
{
  /* Output the given pixel value as a symbol. */
  output(dinfo, c);
  /* Issue Clear codes often enough to keep the reader from ratcheting up
   * its symbol size.
   */
  if (dinfo->code_counter < dinfo->maxcode) {
    dinfo->code_counter++;
  } else {
    output(dinfo, dinfo->ClearCode);
    dinfo->code_counter = dinfo->ClearCode + 2;	/* reset the counter */
  }
}


LOCAL(void)
compress_term (gif_dest_ptr dinfo)
/* Clean up at end */
{
  /* Send an EOF code */
  output(dinfo, dinfo->EOFCode);
  /* Flush the bit-packing buffer */
  if (dinfo->cur_bits > 0) {
    CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF);
  }
  /* Flush the packet buffer */
  flush_packet(dinfo);
}


/* GIF header construction */


LOCAL(void)
put_word (gif_dest_ptr dinfo, unsigned int w)
/* Emit a 16-bit word, LSB first */
{
  putc(w & 0xFF, dinfo->pub.output_file);
  putc((w >> 8) & 0xFF, dinfo->pub.output_file);
}


LOCAL(void)
put_3bytes (gif_dest_ptr dinfo, int val)
/* Emit 3 copies of same byte value --- handy subr for colormap construction */
{
  putc(val, dinfo->pub.output_file);
  putc(val, dinfo->pub.output_file);
  putc(val, dinfo->pub.output_file);
}


LOCAL(void)
emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap)
/* Output the GIF file header, including color map */
/* If colormap==NULL, synthesize a gray-scale colormap */
{
  int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte;
  int cshift = dinfo->cinfo->data_precision - 8;
  int i;

  if (num_colors > 256)
    ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors);
  /* Compute bits/pixel and related values */
  BitsPerPixel = 1;
  while (num_colors > (1 << BitsPerPixel))
    BitsPerPixel++;
  ColorMapSize = 1 << BitsPerPixel;
  if (BitsPerPixel <= 1)
    InitCodeSize = 2;
  else
    InitCodeSize = BitsPerPixel;
  /*
   * Write the GIF header.
   * Note that we generate a plain GIF87 header for maximum compatibility.
   */
  putc('G', dinfo->pub.output_file);
  putc('I', dinfo->pub.output_file);
  putc('F', dinfo->pub.output_file);
  putc('8', dinfo->pub.output_file);
  putc('7', dinfo->pub.output_file);
  putc('a', dinfo->pub.output_file);
  /* Write the Logical Screen Descriptor */
  put_word(dinfo, (unsigned int) dinfo->cinfo->output_width);
  put_word(dinfo, (unsigned int) dinfo->cinfo->output_height);
  FlagByte = 0x80;		/* Yes, there is a global color table */
  FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */
  FlagByte |= (BitsPerPixel-1);	/* size of global color table */
  putc(FlagByte, dinfo->pub.output_file);
  putc(0, dinfo->pub.output_file); /* Background color index */
  putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */
  /* Write the Global Color Map */
  /* If the color map is more than 8 bits precision, */
  /* we reduce it to 8 bits by shifting */
  for (i=0; i < ColorMapSize; i++) {
    if (i < num_colors) {
      if (colormap != NULL) {
	if (dinfo->cinfo->out_color_space == JCS_RGB) {
	  /* Normal case: RGB color map */
	  putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file);
	  putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file);
	  putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file);
	} else {
	  /* Grayscale "color map": possible if quantizing grayscale image */
	  put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift);
	}
      } else {
	/* Create a gray-scale map of num_colors values, range 0..255 */
	put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1));
      }
    } else {
      /* fill out the map to a power of 2 */
      put_3bytes(dinfo, 0);
    }
  }
  /* Write image separator and Image Descriptor */
  putc(',', dinfo->pub.output_file); /* separator */
  put_word(dinfo, 0);		/* left/top offset */
  put_word(dinfo, 0);
  put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */
  put_word(dinfo, (unsigned int) dinfo->cinfo->output_height);
  /* flag byte: not interlaced, no local color map */
  putc(0x00, dinfo->pub.output_file);
  /* Write Initial Code Size byte */
  putc(InitCodeSize, dinfo->pub.output_file);

  /* Initialize for "compression" of image data */
  compress_init(dinfo, InitCodeSize+1);
}


/*
 * Startup: write the file header.
 */

METHODDEF(void)
start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
  gif_dest_ptr dest = (gif_dest_ptr) dinfo;

  if (cinfo->quantize_colors)
    emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap);
  else
    emit_header(dest, 256, (JSAMPARRAY) NULL);
}


/*
 * Write some pixel data.
 * In this module rows_supplied will always be 1.
 */

METHODDEF(void)
put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
		JDIMENSION rows_supplied)
{
  gif_dest_ptr dest = (gif_dest_ptr) dinfo;
  register JSAMPROW ptr;
  register JDIMENSION col;

  ptr = dest->pub.buffer[0];
  for (col = cinfo->output_width; col > 0; col--) {
    compress_pixel(dest, GETJSAMPLE(*ptr++));
  }
}


/*
 * Finish up at the end of the file.
 */

METHODDEF(void)
finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
  gif_dest_ptr dest = (gif_dest_ptr) dinfo;

  /* Flush "compression" mechanism */
  compress_term(dest);
  /* Write a zero-length data block to end the series */
  putc(0, dest->pub.output_file);
  /* Write the GIF terminator mark */
  putc(';', dest->pub.output_file);
  /* Make sure we wrote the output file OK */
  fflush(dest->pub.output_file);
  if (ferror(dest->pub.output_file))
    ERREXIT(cinfo, JERR_FILE_WRITE);
}


/*
 * The module selection routine for GIF format output.
 */

GLOBAL(djpeg_dest_ptr)
jinit_write_gif (j_decompress_ptr cinfo)
{
  gif_dest_ptr dest;

  /* Create module interface object, fill in method pointers */
  dest = (gif_dest_ptr)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				  SIZEOF(gif_dest_struct));
  dest->cinfo = cinfo;		/* make back link for subroutines */
  dest->pub.start_output = start_output_gif;
  dest->pub.put_pixel_rows = put_pixel_rows;
  dest->pub.finish_output = finish_output_gif;

  if (cinfo->out_color_space != JCS_GRAYSCALE &&
      cinfo->out_color_space != JCS_RGB)
    ERREXIT(cinfo, JERR_GIF_COLORSPACE);

  /* Force quantization if color or if > 8 bits input */
  if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) {
    /* Force quantization to at most 256 colors */
    cinfo->quantize_colors = TRUE;
    if (cinfo->desired_number_of_colors > 256)
      cinfo->desired_number_of_colors = 256;
  }

  /* Calculate output image dimensions so we can allocate space */
  jpeg_calc_output_dimensions(cinfo);

  if (cinfo->output_components != 1) /* safety check: just one component? */
    ERREXIT(cinfo, JERR_GIF_BUG);

  /* Create decompressor output buffer. */
  dest->pub.buffer = (*cinfo->mem->alloc_sarray)
    ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1);
  dest->pub.buffer_height = 1;

  return (djpeg_dest_ptr) dest;
}

#endif /* GIF_SUPPORTED */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久更新时间 | 日韩欧美精品三级| 亚洲美女电影在线| www.久久久久久久久| 国产精品久久久久久久久晋中| 国产精品国产三级国产普通话99 | 国产成人精品免费| 91视频免费播放| 欧美中文字幕一二三区视频| 制服视频三区第一页精品| 欧美大胆一级视频| 中文字幕亚洲综合久久菠萝蜜| 亚洲丰满少妇videoshd| 国产一区二区三区四区在线观看| 粉嫩av一区二区三区在线播放| 欧美亚洲综合另类| 国产亚洲午夜高清国产拍精品| 国产精品日韩成人| 久久99精品网久久| 欧美天堂亚洲电影院在线播放| 国产拍揄自揄精品视频麻豆| 亚洲国产wwwccc36天堂| 99久久精品免费看| 日韩精品一区在线观看| 亚洲国产色一区| 91色九色蝌蚪| 欧美国产精品中文字幕| 日韩主播视频在线| 色婷婷亚洲精品| 国产精品久久久久婷婷二区次| 麻豆一区二区三| 色婷婷av一区| 中文字幕欧美一| 国产高清视频一区| 亚洲精品在线网站| 麻豆精品在线视频| 3atv在线一区二区三区| 洋洋成人永久网站入口| 99精品视频免费在线观看| 国产午夜亚洲精品午夜鲁丝片| 日产国产欧美视频一区精品 | 亚洲一二三级电影| 色一区在线观看| 亚洲影视在线播放| 在线观看欧美日本| 五月天国产精品| 8v天堂国产在线一区二区| 天堂午夜影视日韩欧美一区二区| 欧美久久久久久久久| 亚洲电影欧美电影有声小说| 亚洲一区二区三区不卡国产欧美| 亚洲欧洲精品一区二区三区 | 亚洲欧美影音先锋| 1区2区3区国产精品| 亚洲精品欧美专区| 亚洲福利一区二区三区| 亚洲.国产.中文慕字在线| 五月婷婷另类国产| 麻豆国产精品官网| 看国产成人h片视频| 日日摸夜夜添夜夜添国产精品| 色哟哟一区二区三区| 日韩成人精品视频| 国产精品久久久久影院亚瑟| 91久久线看在观草草青青| 亚洲裸体xxx| 精品欧美久久久| 日本韩国欧美国产| 男男gaygay亚洲| 国产精品拍天天在线| 欧美日韩另类一区| 成人免费高清视频在线观看| 亚洲国产精品尤物yw在线观看| 欧美精品一区视频| 欧美午夜片在线看| 国产在线精品不卡| 偷窥少妇高潮呻吟av久久免费| 久久久久久久久99精品| 精品视频一区二区三区免费| 国产成人在线观看| 黄色小说综合网站| 日韩成人午夜精品| 亚洲chinese男男1069| 一区二区三区影院| 国产午夜精品久久| 精品粉嫩aⅴ一区二区三区四区| 色综合视频一区二区三区高清| 国产一区二区0| 精品一区二区三区免费播放| 亚洲国产成人av网| 亚洲精品自拍动漫在线| 成人黄页在线观看| 国产日产欧美一区二区视频| 久久99久久久久| 欧美日韩一区视频| 亚洲图片有声小说| 日本精品一级二级| 夜夜嗨av一区二区三区四季av | 91丨porny丨国产| 国产精品久久久久久久岛一牛影视 | 亚洲综合久久久| 色视频欧美一区二区三区| 一区二区三区欧美视频| 日本道精品一区二区三区| 亚洲综合网站在线观看| 在线免费不卡电影| 蜜桃av一区二区三区| 精品国精品国产| 久久国产视频网| 精品99999| 国产精品久久久久久久第一福利| 国产精品电影院| 亚洲国产欧美在线| 久久精品国产99国产精品| 国产一区二区三区免费在线观看| 国产一区二区三区在线观看免费| 成人少妇影院yyyy| 欧美日韩五月天| 久久精品一二三| 亚洲一区二区三区国产| 久久精品免费观看| 色狠狠一区二区| www日韩大片| 亚洲国产成人高清精品| 国内精品嫩模私拍在线| 99精品视频在线观看免费| 欧美一区二区视频观看视频| 国产三级一区二区三区| 日韩电影在线一区| av在线综合网| 精品国产乱码久久久久久牛牛| 一区二区三区欧美| 粉嫩一区二区三区性色av| 欧美日韩三级在线| 亚洲欧美日韩国产一区二区三区 | 欧美精品v日韩精品v韩国精品v| 国产日韩欧美高清在线| 男女男精品视频| 欧美三级日韩三级国产三级| 国产精品乱码一区二区三区软件 | 国产黄色精品视频| 日韩电影在线免费看| 又紧又大又爽精品一区二区| 国产精品美女一区二区三区| 久久久777精品电影网影网| 日韩一级二级三级精品视频| 91精品中文字幕一区二区三区| 欧美综合色免费| 欧美日韩一区二区三区四区五区| 99v久久综合狠狠综合久久| 北岛玲一区二区三区四区| 成人国产精品免费网站| 成人av电影在线观看| 一区二区三区在线免费视频| 国产乱人伦偷精品视频免下载| 毛片av一区二区| 国产在线播放一区二区三区| 国产91精品在线观看| 成人黄色片在线观看| 在线看一区二区| 日韩三区在线观看| 国产女人水真多18毛片18精品视频| 国产精品卡一卡二卡三| 一区在线观看视频| 一区二区视频在线| 欧洲精品视频在线观看| 亚洲成人一区二区在线观看| 在线播放中文字幕一区| 蜜桃精品视频在线观看| 国产欧美日韩精品一区| 9人人澡人人爽人人精品| 亚洲一级电影视频| 日韩一本二本av| 国产女人18毛片水真多成人如厕 | 久久―日本道色综合久久| 中文幕一区二区三区久久蜜桃| 亚洲精品国产精品乱码不99| 国产在线观看免费一区| 色欧美片视频在线观看| 久久久精品欧美丰满| 日韩影院免费视频| 91美女片黄在线观看91美女| 久久综合精品国产一区二区三区| 亚洲一区二区视频| 91啪在线观看| 国产精品无人区| 国产.精品.日韩.另类.中文.在线.播放| 色哟哟精品一区| 日韩中文欧美在线| av在线播放一区二区三区| 精品理论电影在线| 青青草国产成人av片免费| 色爱区综合激月婷婷| 国产精品久久久久久久久果冻传媒| 看电视剧不卡顿的网站| 日韩小视频在线观看专区| 午夜精品久久久久久久99樱桃| 色婷婷综合视频在线观看| 亚洲欧美一区二区三区孕妇| 99re视频精品|